Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub fn parse_command(args: &[String], flags: &Flags) -> Result<Value, ParseError
let rest: Vec<&str> = args[1..].iter().map(|s| s.as_str()).collect();
let id = gen_id();

if flags.annotate && cmd != "screenshot" {
if flags.cli_annotate && cmd != "screenshot" {
eprintln!(
"{} --annotate only applies to the screenshot command",
color::warning_indicator()
Expand Down Expand Up @@ -1863,6 +1863,7 @@ mod tests {
cli_proxy: false,
cli_proxy_bypass: false,
cli_allow_file_access: false,
cli_annotate: false,
annotate: false,
color_scheme: None,
}
Expand Down
16 changes: 16 additions & 0 deletions cli/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ pub struct Flags {
pub cli_proxy: bool,
pub cli_proxy_bypass: bool,
pub cli_allow_file_access: bool,
pub cli_annotate: bool,
}

pub fn parse_flags(args: &[String]) -> Flags {
Expand Down Expand Up @@ -293,6 +294,7 @@ pub fn parse_flags(args: &[String]) -> Flags {
cli_proxy: false,
cli_proxy_bypass: false,
cli_allow_file_access: false,
cli_annotate: false,
};

let mut i = 0;
Expand Down Expand Up @@ -429,6 +431,7 @@ pub fn parse_flags(args: &[String]) -> Flags {
"--annotate" => {
let (val, consumed) = parse_bool_arg(args, i);
flags.annotate = val;
flags.cli_annotate = true;
if consumed { i += 1; }
}
"--color-scheme" => {
Expand Down Expand Up @@ -658,6 +661,19 @@ mod tests {
assert!(flags.cli_profile);
}

#[test]
fn test_cli_annotate_tracking() {
let flags = parse_flags(&args("--annotate screenshot"));
assert!(flags.cli_annotate);
assert!(flags.annotate);
}

#[test]
fn test_cli_annotate_not_set_without_flag() {
let flags = parse_flags(&args("screenshot"));
assert!(!flags.cli_annotate);
}

#[test]
fn test_cli_multiple_flags_tracking() {
let flags = parse_flags(&args(
Expand Down