From 77906bad500da5abb2f94b60ef9250616820aff7 Mon Sep 17 00:00:00 2001 From: Rohan Patnaik Date: Sun, 10 May 2026 13:52:45 +0530 Subject: [PATCH 1/3] fix(sheets): require values for append helper --- .changeset/sheets-append-require-values.md | 5 +++++ .../src/helpers/sheets.rs | 22 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 .changeset/sheets-append-require-values.md diff --git a/.changeset/sheets-append-require-values.md b/.changeset/sheets-append-require-values.md new file mode 100644 index 00000000..9833c73d --- /dev/null +++ b/.changeset/sheets-append-require-values.md @@ -0,0 +1,5 @@ +--- +"@googleworkspace/cli": patch +--- + +Require row data when using `gws sheets +append`. diff --git a/crates/google-workspace-cli/src/helpers/sheets.rs b/crates/google-workspace-cli/src/helpers/sheets.rs index 4357edec..51447bf9 100644 --- a/crates/google-workspace-cli/src/helpers/sheets.rs +++ b/crates/google-workspace-cli/src/helpers/sheets.rs @@ -43,13 +43,15 @@ impl Helper for SheetsHelper { Arg::new("values") .long("values") .help("Comma-separated values (simple strings)") - .value_name("VALUES"), + .value_name("VALUES") + .required_unless_present("json-values"), ) .arg( Arg::new("json-values") .long("json-values") .help("JSON array of rows, e.g. '[[\"a\",\"b\"],[\"c\",\"d\"]]'") - .value_name("JSON"), + .value_name("JSON") + .required_unless_present("values"), ) .arg( Arg::new("range") @@ -522,4 +524,20 @@ mod tests { assert!(subcommands.contains(&"+append")); assert!(subcommands.contains(&"+read")); } + + #[test] + fn test_append_requires_values_or_json_values() { + let helper = SheetsHelper; + let cmd = helper.inject_commands( + Command::new("sheets"), + &crate::discovery::RestDescription::default(), + ); + + let result = cmd.try_get_matches_from(["sheets", "+append", "--spreadsheet", "123"]); + + assert!( + result.is_err(), + "+append should require --values or --json-values" + ); + } } From 083d5a65ad839f1c62f35e3298727118a8883e95 Mon Sep 17 00:00:00 2001 From: Rohan Patnaik Date: Sun, 10 May 2026 15:32:11 +0530 Subject: [PATCH 2/3] fix(sheets): reject ambiguous append input --- .../src/helpers/sheets.rs | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/crates/google-workspace-cli/src/helpers/sheets.rs b/crates/google-workspace-cli/src/helpers/sheets.rs index 51447bf9..13961096 100644 --- a/crates/google-workspace-cli/src/helpers/sheets.rs +++ b/crates/google-workspace-cli/src/helpers/sheets.rs @@ -44,14 +44,16 @@ impl Helper for SheetsHelper { .long("values") .help("Comma-separated values (simple strings)") .value_name("VALUES") - .required_unless_present("json-values"), + .required_unless_present("json-values") + .conflicts_with("json-values"), ) .arg( Arg::new("json-values") .long("json-values") .help("JSON array of rows, e.g. '[[\"a\",\"b\"],[\"c\",\"d\"]]'") .value_name("JSON") - .required_unless_present("values"), + .required_unless_present("values") + .conflicts_with("values"), ) .arg( Arg::new("range") @@ -540,4 +542,28 @@ mod tests { "+append should require --values or --json-values" ); } + + #[test] + fn test_append_rejects_values_and_json_values_together() { + let helper = SheetsHelper; + let cmd = helper.inject_commands( + Command::new("sheets"), + &crate::discovery::RestDescription::default(), + ); + + let err = cmd + .try_get_matches_from([ + "sheets", + "+append", + "--spreadsheet", + "123", + "--values", + "a,b", + "--json-values", + r#"["c","d"]"#, + ]) + .unwrap_err(); + + assert_eq!(err.kind(), clap::error::ErrorKind::ArgumentConflict); + } } From 33c3c34ce26c2d182230f91e49aeb4653bfcc3a8 Mon Sep 17 00:00:00 2001 From: Rohan Patnaik Date: Sun, 10 May 2026 15:39:00 +0530 Subject: [PATCH 3/3] test(sheets): assert missing append values error --- crates/google-workspace-cli/src/helpers/sheets.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/google-workspace-cli/src/helpers/sheets.rs b/crates/google-workspace-cli/src/helpers/sheets.rs index 13961096..43b4a3c4 100644 --- a/crates/google-workspace-cli/src/helpers/sheets.rs +++ b/crates/google-workspace-cli/src/helpers/sheets.rs @@ -535,12 +535,11 @@ mod tests { &crate::discovery::RestDescription::default(), ); - let result = cmd.try_get_matches_from(["sheets", "+append", "--spreadsheet", "123"]); + let err = cmd + .try_get_matches_from(["sheets", "+append", "--spreadsheet", "123"]) + .unwrap_err(); - assert!( - result.is_err(), - "+append should require --values or --json-values" - ); + assert_eq!(err.kind(), clap::error::ErrorKind::MissingRequiredArgument); } #[test]