fix: gws auth setup --help prints usage instead of running wizard#442
fix: gws auth setup --help prints usage instead of running wizard#442anshul-garg27 wants to merge 1 commit intogoogleworkspace:mainfrom
gws auth setup --help prints usage instead of running wizard#442Conversation
Previously, `gws auth setup --help` would start the setup wizard (and fail if gcloud was not installed). Now it early-returns with a usage message before any side effects. Adds tests to verify --help, -h, and --help combined with other flags all return Ok without starting the wizard.
🦋 Changeset detectedLatest commit: 6121656 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Summary of ChangesHello, 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 resolves an issue where the Highlights
Changelog
Activity
Using Gemini Code AssistThe 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
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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request correctly implements the --help and -h flags for the gws auth setup command, preventing the setup wizard from running unintentionally. The change includes an early return in run_setup and adds corresponding tests to verify the new behavior. My feedback includes a suggestion to improve the maintainability of the new help message by extracting it into a constant.
| if args.iter().any(|a| a == "--help" || a == "-h") { | ||
| println!( | ||
| "Usage: gws auth setup [options]\n\n\ | ||
| Configure a GCP project, enable Workspace APIs, and create OAuth\n\ | ||
| credentials — all in one guided wizard.\n\n\ | ||
| Options:\n\ | ||
| \x20 --project <ID> Use an existing GCP project instead of creating one\n\ | ||
| \x20 --dry-run Show what would be done without making changes\n\ | ||
| \x20 --login Run `gws auth login` after successful setup\n\ | ||
| \x20 -h, --help Show this help message" | ||
| ); | ||
| return Ok(()); | ||
| } |
There was a problem hiding this comment.
For better maintainability and readability, it's a good practice to extract string literals, especially multi-line ones, into constants. This makes the help text easier to find and modify without digging into the logic. While a module-level const would be ideal, defining it inside the if block is still a good improvement that can be applied within the scope of this diff.
if args.iter().any(|a| a == "--help" || a == "-h") {
const SETUP_USAGE: &str = "Usage: gws auth setup [options]\n\n\
Configure a GCP project, enable Workspace APIs, and create OAuth\n\
credentials — all in one guided wizard.\n\n\
Options:\n\
\x20 --project <ID> Use an existing GCP project instead of creating one\n\
\x20 --dry-run Show what would be done without making changes\n\
\x20 --login Run `gws auth login` after successful setup\n\
\x20 -h, --help Show this help message";
println!("{SETUP_USAGE}");
return Ok(());
}There was a problem hiding this comment.
Noted, but keeping the string inline here for simplicity — this is a small, self-contained usage block (8 lines) in a single function. Extracting it to a constant would add indirection without much benefit at this scale. Happy to refactor if the maintainer prefers it.
Summary
gws auth setup --help(and-h) now prints a usage message and exits cleanlyRoot cause
run_setup()insrc/setup.rsparsed arguments but never checked for--help/-h, so the wizard always started. The help flag was silently ignored byparse_setup_args.Fix
Added an early-return at the top of
run_setup()that checks for--help/-hbefore any side effects (gcloud checks, TUI wizard, etc.).Test plan
run_setup(&["--help"])returnsOk(())without starting wizardrun_setup(&["-h"])returnsOk(())run_setup(&["--project", "my-proj", "--help"])returnsOk(())(help takes priority)Closes #280