diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/args.rs | 75 |
1 files changed, 74 insertions, 1 deletions
diff --git a/src/args.rs b/src/args.rs index baddb47..558a0b1 100644 --- a/src/args.rs +++ b/src/args.rs @@ -121,6 +121,18 @@ pub struct Args { #[clap(short = 'C', long, value_parser)] pub directory: Option<PathBuf>, + /// Print the working directory when starting. + // TODO implement + // TODO automatically with -C or recursion or decide that this is a bad GNU feature + #[cfg(feature = "full")] + #[clap(short = 'w', long, overrides_with = "print_directory", overrides_with = "no_print_directory")] + pub print_directory: bool, + + /// Do not print the working directory when starting, even when running with -C or recursively. + #[cfg(feature = "full")] + #[clap(long, overrides_with = "print_directory", overrides_with = "no_print_directory")] + pub no_print_directory: bool, + /// Target names or macro definitions. /// /// If no target is specified, while make is processing the makefiles, the first @@ -221,6 +233,7 @@ impl Args { if self.touch { result.push('t'); } + // TODO decide whether or not print_directory should go here too result } } @@ -255,6 +268,10 @@ mod test { touch: false, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec![], } ); @@ -262,7 +279,7 @@ mod test { #[test] fn kitchen_sink_args() { - let args = "makers -eiknpqrstf foo -f bruh bar baz=yeet"; + let args = "makers -eiknpqrstwf foo -f bruh bar baz=yeet"; let args = Args::from_given_args_and_given_env( args.split_whitespace().map(OsString::from), String::new(), @@ -283,6 +300,10 @@ mod test { touch: true, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: true, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec!["bar".into(), "baz=yeet".into()], } ); @@ -311,6 +332,10 @@ mod test { touch: false, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec![], } ); @@ -339,6 +364,42 @@ mod test { touch: false, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, + targets_or_macros: vec![], + } + ); + } + + #[test] + fn print_directory_wrestling() { + let args = "makers -w --no-print-directory -w -w --no-print-directory --no-print-directory -w --no-print-directory"; + let args = Args::from_given_args_and_given_env( + args.split_whitespace().map(OsString::from), + String::new(), + ); + assert_eq!( + args, + Args { + environment_overrides: false, + makefile: vec![], + ignore_errors: false, + keep_going: false, + dry_run: false, + print_everything: false, + question: false, + no_builtin_rules: false, + no_keep_going: false, + silent: false, + touch: false, + #[cfg(feature = "full")] + directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: true, targets_or_macros: vec![], } ); @@ -365,6 +426,10 @@ mod test { touch: false, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec![], } ); @@ -391,6 +456,10 @@ mod test { touch: false, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec![], } ); @@ -420,6 +489,10 @@ mod test { touch: true, #[cfg(feature = "full")] directory: None, + #[cfg(feature = "full")] + print_directory: false, + #[cfg(feature = "full")] + no_print_directory: false, targets_or_macros: vec!["foo=bar".into(), "bar".into(), "baz=yeet".into()], } ); |