diff --git a/cli/src/cli/generate/fig.rs b/cli/src/cli/generate/fig.rs index d22ed88..058dd4e 100644 --- a/cli/src/cli/generate/fig.rs +++ b/cli/src/cli/generate/fig.rs @@ -23,10 +23,6 @@ pub struct Fig { /// File on where to save the generated Fig spec #[clap(long, value_hint = clap::ValueHint::FilePath)] out_file: Option, - - /// Whether to output to stdout - #[clap(long, action = clap::ArgAction::SetTrue, required_unless_present="out_file", overrides_with = "out_file")] - stdout: Option, } #[derive(Serialize, Deserialize, Clone, PartialEq, Eq)] @@ -320,7 +316,6 @@ impl Fig { let completes = spec.complete; Fig::fill_args_complete(args, completes); let j = serde_json::to_string_pretty(&main_command).unwrap(); - let path = self.out_file.clone().unwrap_or(PathBuf::from("./usage.ts")); let mut result = format!("const completionSpec: Fig.Spec = {j}"); let generators = main_command.get_generators(); @@ -349,14 +344,14 @@ impl Fig { ) }); - let output_to_str = self.stdout.unwrap_or(true); - if output_to_str { - print!("{result}"); - Ok(()) - } else { + if let Some(path) = &self.out_file { result = [Fig::get_prescript(), result, Fig::get_postscript()].join("\n\n"); - write(&path, result.as_str()) + write(path, result.as_str())?; + } else { + print!("{result}"); } + + Ok(()) } fn get_prescript() -> String { diff --git a/cli/usage.usage.kdl b/cli/usage.usage.kdl index b2481c3..a4119b3 100644 --- a/cli/usage.usage.kdl +++ b/cli/usage.usage.kdl @@ -64,7 +64,6 @@ cmd "generate" subcommand_required=true { flag "--out-file" help="File on where to save the generated Fig spec" { arg "" } - flag "--stdout" help="Whether to output to stdout" } cmd "markdown" { alias "md" diff --git a/docs/cli/completions.md b/docs/cli/completions.md index 9947eb6..018a31a 100644 --- a/docs/cli/completions.md +++ b/docs/cli/completions.md @@ -26,7 +26,7 @@ mycli -- fig/Amazon Q: ```bash -usage g completion fig mycli -f ./mycli.usage.kdl > ~/.config/fig/completions/mycli.fish +usage g fig -f ./mycli.usage.kdl > ./mycli.fig.ts mycli -- ``` diff --git a/docs/cli/reference.md b/docs/cli/reference.md index 7ec84fa..da83968 100644 --- a/docs/cli/reference.md +++ b/docs/cli/reference.md @@ -152,10 +152,6 @@ raw string spec input File on where to save the generated Fig spec -#### `--stdout` - -Whether to output to stdout - ## `usage generate markdown` - **Usage**: `usage generate markdown `