Skip to content

fix(gmail): rename +read --format to --body-format to avoid global flag collision#751

Open
hoyt-harness wants to merge 1 commit intogoogleworkspace:mainfrom
hoyt-harness:fix/740-read-format-collision
Open

fix(gmail): rename +read --format to --body-format to avoid global flag collision#751
hoyt-harness wants to merge 1 commit intogoogleworkspace:mainfrom
hoyt-harness:fix/740-read-format-collision

Conversation

@hoyt-harness
Copy link
Copy Markdown

Problem

Closes #740 (partial — format-collision sub-issue)

gmail +read defined a local --format arg with default_value("text") and
value_parser(["text", "json"]). The root --format flag is declared
.global(true), so clap propagated the "text" default up to the root
ArgMatches. main.rs reads the global --format value, gets "text",
doesn't recognise it as a valid output format (valid: json, table, yaml,
csv), and emits a spurious warning on every +read invocation:

warning: unknown output format 'text'; falling back to json (valid options: json, table, yaml, csv)

Fix

Rename the +read local arg from --format to --body-format. The name
collision is eliminated; the global --format flag is now unambiguous when
+read is the active subcommand.

Behaviour is otherwise unchanged:

Flag Effect
(omit) Render decoded message body as plain text (default)
--body-format text Same as above
--body-format json Return the full structured JSON object

The after_help example is updated from --format json to --body-format json.

Migration note

Scripts or aliases using gws gmail +read --format json must be updated to
gws gmail +read --body-format json.

Testing

  • cargo clippy -- -D warnings: clean
  • cargo test: 699 pass, 2 fail (pre-existing test_get_quota_project_* ADC
    environment tests unrelated to this change — confirmed failing on unmodified
    upstream/main too)

Also collapses a pre-existing clippy::collapsible_match in helpers/script.rs
that surfaces on every fresh branch from upstream/main (same fix as PRs #744,
#747, #748, #749, #750).

🤖 Generated with Claude Code

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 22, 2026

🦋 Changeset detected

Latest commit: 09395aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@googleworkspace-bot googleworkspace-bot added the area: core Core CLI parsing, commands, error handling, utilities label Apr 22, 2026
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a CLI argument collision where a local subcommand flag was conflicting with a global flag, leading to incorrect default value propagation and unnecessary warnings. By renaming the local argument, the CLI behavior is now unambiguous. The change also includes minor code maintenance to simplify match logic.

Highlights

  • Flag Renaming: Renamed the local --format argument in gmail +read to --body-format to resolve a naming collision with the global --format flag.
  • Warning Resolution: Eliminated spurious warnings caused by the global flag incorrectly propagating default values to the subcommand.
  • Code Cleanup: Refactored a collapsible match pattern in helpers/script.rs to improve code readability.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request resolves a flag collision by renaming the local --format argument to --body-format within the gmail +read command. It also includes a minor refactor in script.rs to use match guards for better readability. A review comment correctly identified that the updated documentation example used an incorrect field name for jq filtering, which would result in null output for users.

Comment thread crates/google-workspace-cli/src/helpers/gmail/mod.rs Outdated
…ag collision

The +read subcommand defined a local --format arg (default: "text") that shared
its name with the global --format flag (declared .global(true)).  clap propagated
the "text" default up to the root matches, causing main.rs to emit a spurious
"unknown output format 'text'" warning on every +read invocation.

Rename the arg to --body-format to eliminate the collision.  The global --format
flag is now unambiguous for +read; --body-format text (default) renders plain text
and --body-format json returns the structured JSON object as before.

Also collapse pre-existing clippy::collapsible_match in helpers/script.rs.
@hoyt-harness hoyt-harness force-pushed the fix/740-read-format-collision branch from f26c7b8 to 09395aa Compare April 22, 2026 22:01
@hoyt-harness
Copy link
Copy Markdown
Author

Fixed — the example now uses .body_text which is the correct field name on the serialized struct. Good catch.

@googleworkspace-bot
Copy link
Copy Markdown
Collaborator

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request resolves a naming collision between the local --format argument in the gmail +read command and the global --format flag by renaming the local argument to --body-format. The changes include updates to the CLI argument definition, help documentation, and the internal handler. Additionally, a minor refactor was performed in script.rs to use match guards for JSON file processing. I have no feedback to provide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Core CLI parsing, commands, error handling, utilities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multiple commands return exit 0 with empty stdout when output serialization fails, silently swallowing successful API responses

2 participants