Skip to content

Craft Anything: understand how any software works, and craft your own.

Rust

Stop advising `report --format` in the CLI help (#419)

NetterSilver9896e18c2817
diff --git a/apps/craft-anything-cli/src/main.rs b/apps/craft-anything-cli/src/main.rs
index 696cdab5..17e0c5f5 100644
--- a/apps/craft-anything-cli/src/main.rs
+++ b/apps/craft-anything-cli/src/main.rs
@@ -26,7 +26,7 @@ pub static INTERRUPTED: AtomicBool = AtomicBool::new(false);
#[derive(Debug, Parser)]
#[command(name = "craft-anything-cli", version, about = "Craft Anything on the command line: every tool, the MCP server, setup and doctor.")]
#[command(after_help = "Every tool is also a subcommand: `craft-anything-cli commands` lists them, `craft-anything-cli <tool> --help` shows its options.\n\
-When a tool has its own --format option (core-target-open, report, ...), --format after the tool name goes to the tool; pick the output with --output-format (or --format before the tool name).")]
+When a tool has its own --format option (core-target-open, ...), --format after the tool name goes to the tool; pick the output with --output-format (or --format before the tool name). `report` has no format option of its own: use `report --html` for HTML.")]
pub struct Cli {
/// Output format. `--output-format` always means this, even after a tool that has its own `--format`.
#[arg(long, global = true, value_enum, default_value_t = Format::Json, alias = "output-format")]
diff --git a/apps/craft-anything-cli/tests/cli.rs b/apps/craft-anything-cli/tests/cli.rs
index 2d833679..6d8b799e 100644
--- a/apps/craft-anything-cli/tests/cli.rs
+++ b/apps/craft-anything-cli/tests/cli.rs
@@ -205,3 +205,13 @@ fn a_bare_argument_is_the_path_even_when_other_options_sort_first() {
let model: Value = serde_json::from_slice(&cli(&["formats-ai-weights-show", "--deep", path], cfg.path()).stdout).unwrap();
assert!(!model["error"]["message"].as_str().unwrap_or_default().contains("unknown variant"), "{model}");
}
+
+/// #254: the top-level help must not advise `report --format`, which the parser sends to the global output format.
+#[test]
+fn help_does_not_advise_a_report_format_option() {
+ let cfg = tempfile::tempdir().unwrap();
+ let help = cli(&["--help"], cfg.path());
+ assert!(help.success);
+ assert!(!help.stdout_text().contains("(core-target-open, report"));
+ assert_eq!(cli(&["report", "--format", "html"], cfg.path()).code, Some(2));
+}