1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use clap::Parser;
/// Top-level CLI options for help-probe.
#[derive(Parser, Debug)]
#[command(
name = "help-probe",
version,
about = "Run a command's help and parse its usage"
)]
pub struct Cli {
/// The command and its arguments to inspect.
///
/// Example:
/// help-probe -- ls --help
/// help-probe -- ffmpeg -h
/// help-probe -- myprog --usage
#[arg(trailing_var_arg = true, required = true)]
pub cmd: Vec<String>,
/// Timeout in seconds for the target command
#[arg(long, default_value_t = 3)]
pub timeout_secs: u64,
/// Run command even when no help flag is present (no confirmation).
#[arg(long)]
pub force: bool,
/// Show raw stdout/stderr from the command.
#[arg(long)]
pub verbose: bool,
/// Emit JSON instead of human-readable text.
#[arg(long)]
pub json: bool,
/// Generate shell completion script.
/// Supported shells: bash, zsh, fish, powershell, nushell
#[arg(long, value_name = "SHELL")]
pub generate_completion: Option<String>,
/// Output file for completion/builder/docs generation (prompts if file exists).
/// If not specified, output is written to stdout.
#[arg(long, value_name = "FILE")]
pub output: Option<std::path::PathBuf>,
/// Validate a command invocation.
/// Validates the provided command and arguments against the probed command spec.
#[arg(long)]
pub validate: bool,
/// Generate command builder code.
/// Supported languages: rust, python, javascript, typescript
#[arg(long, value_name = "LANGUAGE")]
pub generate_builder: Option<String>,
/// Recursively discover all subcommands and build complete command tree.
/// This probes each subcommand to discover nested commands, options, and arguments.
#[arg(long)]
pub discover_all: bool,
/// Maximum depth for recursive discovery (default: 5).
#[arg(long, default_value_t = 5)]
pub max_depth: usize,
/// Generate API documentation.
/// Supported formats: markdown, html, openapi, jsonschema
#[arg(long, value_name = "FORMAT")]
pub generate_api_docs: Option<String>,
/// Disable caching of probe results.
#[arg(long)]
pub no_cache: bool,
/// Clear cache for the specified command (or all cache if no command provided).
#[arg(long)]
pub clear_cache: bool,
/// Cache directory path (default: ~/.cache/help-probe).
#[arg(long, value_name = "DIR")]
pub cache_dir: Option<String>,
}