Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 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
12 changes: 12 additions & 0 deletions .changeset/helpers-respect-format-flag.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@googleworkspace/cli": patch
---

Fix `--format` flag being silently ignored in sheets and docs helpers

`sheets +append`, `sheets +read`, and `docs +write` all hard-coded
`OutputFormat::default()` (JSON) when calling `executor::execute_method`,
meaning `--format table`, `--format yaml`, and `--format csv` had no effect.
The handlers now read the global `--format` flag from `ArgMatches` and pass
it through to the executor, consistent with how `calendar +agenda` and
`gmail +triage` already behave.
6 changes: 5 additions & 1 deletion crates/google-workspace-cli/src/helpers/docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ TIPS:
Box::pin(async move {
if let Some(matches) = matches.subcommand_matches("+write") {
let (params_str, body_str, scopes) = build_write_request(matches, doc)?;
let output_format = matches
.get_one::<String>("format")
.map(|s| crate::formatter::OutputFormat::from_str(s))
.unwrap_or_default();

let scope_strs: Vec<&str> = scopes.iter().map(|s| s.as_str()).collect();
let (token, auth_method) = match auth::get_token(&scope_strs).await {
Expand Down Expand Up @@ -104,7 +108,7 @@ TIPS:
&pagination,
None,
&crate::helpers::modelarmor::SanitizeMode::Warn,
&crate::formatter::OutputFormat::default(),
&output_format,
false,
)
.await?;
Expand Down
12 changes: 10 additions & 2 deletions crates/google-workspace-cli/src/helpers/sheets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ TIPS:
if let Some(matches) = matches.subcommand_matches("+append") {
let config = parse_append_args(matches);
let (params_str, body_str, scopes) = build_append_request(&config, doc)?;
let output_format = matches
.get_one::<String>("format")
.map(|s| crate::formatter::OutputFormat::from_str(s))
.unwrap_or_default();

let scope_strs: Vec<&str> = scopes.iter().map(|s| s.as_str()).collect();
let (token, auth_method) = match auth::get_token(&scope_strs).await {
Expand Down Expand Up @@ -149,7 +153,7 @@ TIPS:
&pagination,
None,
&crate::helpers::modelarmor::SanitizeMode::Warn,
&crate::formatter::OutputFormat::default(),
&output_format,
false,
)
.await?;
Expand All @@ -160,6 +164,10 @@ TIPS:
if let Some(matches) = matches.subcommand_matches("+read") {
let config = parse_read_args(matches);
let (params_str, scopes) = build_read_request(&config, doc)?;
let output_format = matches
.get_one::<String>("format")
.map(|s| crate::formatter::OutputFormat::from_str(s))
.unwrap_or_default();

// Re-find method
let spreadsheets_res = doc.resources.get("spreadsheets").ok_or_else(|| {
Expand Down Expand Up @@ -192,7 +200,7 @@ TIPS:
&executor::PaginationConfig::default(),
None,
&crate::helpers::modelarmor::SanitizeMode::Warn,
&crate::formatter::OutputFormat::default(),
&output_format,
false,
)
.await?;
Expand Down
Loading