Skip to content

Commit

Permalink
Turn off Binkplayer error on external function fallbacks (#17)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
IFcoltransG authored Dec 4, 2024
1 parent 4b79b61 commit 623d007
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cli-player/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -68,6 +72,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
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;

Expand All @@ -91,7 +96,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

println!();
print_choices(&choices);
println!("?> {i}");
println!("?> {}", i + 1);

Command::Choose(i)
} else {
Expand Down

0 comments on commit 623d007

Please sign in to comment.