From 623d00700924329a57a929bdb94c75bdbecb39dd Mon Sep 17 00:00:00 2001 From: IFcoltransG <47414286+IFcoltransG@users.noreply.github.com> Date: Thu, 5 Dec 2024 02:13:25 +1300 Subject: [PATCH] Turn off Binkplayer error on external function fallbacks (#17) * Correct off-by-one when displaying randomly picked choice number * Add CLI flag for allowing external function fallbacks * Replace opt-out flag with opt-in flag, for erroring on external fallbacks * Rustfmt * Fix docs and help for newly added command --- cli-player/src/main.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cli-player/src/main.rs b/cli-player/src/main.rs index f65ee8e..d9ab99f 100644 --- a/cli-player/src/main.rs +++ b/cli-player/src/main.rs @@ -24,6 +24,10 @@ struct Args { /// Choose options randomly #[arg(short, default_value_t = false)] pub auto_play: bool, + + /// Forbid external function fallbacks + #[arg(short = 'e', default_value_t = false)] + pub forbid_external_fallbacks: bool, } enum Command { @@ -68,6 +72,7 @@ fn main() -> Result<(), Box> { let mut story = Story::new(json_string_without_bom)?; let err_handler = EHandler::new(); story.set_error_handler(err_handler.clone()); + story.set_allow_external_function_fallbacks(!args.forbid_external_fallbacks); let mut end = false; @@ -91,7 +96,7 @@ fn main() -> Result<(), Box> { println!(); print_choices(&choices); - println!("?> {i}"); + println!("?> {}", i + 1); Command::Choose(i) } else {