heddle_cli_args/cli/cli_args/
commands_query.rs1use clap::Args;
5
6use super::HistoricalRevisionArgs;
7
8#[derive(Clone, Debug, Args)]
10pub struct BlameArgs {
11 #[arg(value_name = "PATH")]
13 pub path: String,
14 #[command(flatten)]
15 pub revision: HistoricalRevisionArgs,
16 #[arg(long)]
18 pub context: bool,
19}
20
21#[derive(Clone, Debug, Args)]
22pub struct QueryArgs {
23 #[arg(long, value_name = "FILE")]
25 pub attribution: Option<String>,
26 #[arg(long, requires = "attribution")]
29 pub state: Option<String>,
30 #[arg(long, requires = "attribution")]
32 pub context: bool,
33 #[arg(long)]
35 pub actor: Option<String>,
36 #[arg(long)]
39 pub since: Option<String>,
40 #[arg(long)]
42 pub until: Option<String>,
43 #[arg(long)]
45 pub signal: Option<String>,
46 #[arg(long)]
48 pub symbol: Option<String>,
49 #[arg(long)]
51 pub thread: Option<String>,
52 #[arg(long = "verb")]
55 pub verbs: Vec<String>,
56 #[arg(long, default_value = "100")]
58 pub limit: u32,
59 #[arg(long)]
61 pub include_checkpoints: bool,
62}
63
64#[cfg(test)]
65mod tests {
66 use clap::Parser;
67
68 use crate::cli::{Cli, Commands};
69
70 #[test]
71 fn blame_parses_path_state_and_context() {
72 match Cli::try_parse_from(["heddle", "blame", "src/auth.rs"])
73 .expect("blame path")
74 .command
75 {
76 Commands::Blame(args) => {
77 assert_eq!(args.path, "src/auth.rs");
78 assert!(args.revision.state.is_none());
79 assert!(!args.context);
80 }
81 _ => panic!("expected blame"),
82 }
83 match Cli::try_parse_from([
84 "heddle",
85 "blame",
86 "src/auth.rs",
87 "--state",
88 "HEAD",
89 "--context",
90 ])
91 .expect("blame flags")
92 .command
93 {
94 Commands::Blame(args) => {
95 assert_eq!(args.revision.state.as_deref(), Some("HEAD"));
96 assert!(args.context);
97 }
98 _ => panic!("expected blame"),
99 }
100 }
101}