1use bpaf::{Parser, construct, long};
9
10#[derive(Debug, Clone, PartialEq, Eq, Default)]
18pub struct InitArgs {
19 pub yes: bool,
21}
22
23pub(super) fn init_command() -> impl Parser<InitArgs> {
24 let yes = long("yes")
25 .help("Skip the interactive flow and write a minimal workspace (AUX-007)")
26 .switch();
27 construct!(InitArgs { yes })
28}
29
30#[cfg(test)]
31mod tests {
32 use super::InitArgs;
33 use crate::cli::{Cmd, parse};
34
35 #[test]
36 fn aux_001_init_bare_parses_with_yes_false() {
37 assert_eq!(
38 parse(&["init"]).unwrap(),
39 Cmd::Init(InitArgs { yes: false }),
40 );
41 }
42
43 #[test]
44 fn aux_001_init_with_yes_flag_parses() {
45 assert_eq!(
46 parse(&["init", "--yes"]).unwrap(),
47 Cmd::Init(InitArgs { yes: true }),
48 );
49 }
50
51 #[test]
52 fn aux_001_init_rejects_positional_argument() {
53 let err = parse(&["init", "extra"]).unwrap_err();
54 assert!(
55 !err.is_empty(),
56 "positional argument must produce a diagnostic: {err}",
57 );
58 }
59
60 #[test]
61 fn aux_001_init_rejects_unknown_flag() {
62 let err = parse(&["init", "--no-such-flag"]).unwrap_err();
63 assert!(
64 !err.is_empty(),
65 "unknown flag must produce a diagnostic: {err}",
66 );
67 }
68}