use bpaf::{Parser, construct, long};
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct InitArgs {
pub yes: bool,
}
pub(super) fn init_command() -> impl Parser<InitArgs> {
let yes = long("yes")
.help("Skip the interactive flow and write a minimal workspace (AUX-007)")
.switch();
construct!(InitArgs { yes })
}
#[cfg(test)]
mod tests {
use super::InitArgs;
use crate::cli::{Cmd, parse};
#[test]
fn aux_001_init_bare_parses_with_yes_false() {
assert_eq!(
parse(&["init"]).unwrap(),
Cmd::Init(InitArgs { yes: false }),
);
}
#[test]
fn aux_001_init_with_yes_flag_parses() {
assert_eq!(
parse(&["init", "--yes"]).unwrap(),
Cmd::Init(InitArgs { yes: true }),
);
}
#[test]
fn aux_001_init_rejects_positional_argument() {
let err = parse(&["init", "extra"]).unwrap_err();
assert!(
!err.is_empty(),
"positional argument must produce a diagnostic: {err}",
);
}
#[test]
fn aux_001_init_rejects_unknown_flag() {
let err = parse(&["init", "--no-such-flag"]).unwrap_err();
assert!(
!err.is_empty(),
"unknown flag must produce a diagnostic: {err}",
);
}
}