fix(setup): handle --help/-h before launching setup wizard#592
fix(setup): handle --help/-h before launching setup wizard#592
Conversation
Check for --help/-h at the top of run_setup() before any work that requires gcloud. Previously, running 'gws auth setup --help' would launch the full setup flow. Fixes #280
🦋 Changeset detectedLatest commit: aa5cf5d 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 significantly enhances the user experience for the Highlights
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. Footnotes
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
=======================================
Coverage 69.02% 69.02%
=======================================
Files 42 42
Lines 19298 19311 +13
=======================================
+ Hits 13321 13330 +9
- Misses 5977 5981 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request introduces early handling for --help and -h flags in the gws auth setup command. This prevents the setup wizard from launching and potentially creating projects when users only intend to view usage information. A review comment suggests an improvement: defining the usage string as a const to enhance maintainability and readability, as hardcoding it directly in the println! macro could lead to inconsistencies if command options change.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses an issue where the gws auth setup command would initiate the setup wizard even when users requested help via --help or -h. The change introduces an early exit mechanism that prints usage information and prevents accidental project creation. The review suggests an improvement opportunity to refactor the argument parsing to use a library like clap for enhanced robustness and maintainability, as the current manual parsing and hardcoded usage string could become fragile with future argument changes.
Use clap::Command for gws auth setup argument parsing instead of manual while-loop parser. This gives us: - Automatic --help/-h handling (no manual check needed) - Proper error messages for unknown flags - Consistent with other clap usage in the codebase - Help text stays in sync with actual arguments
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the command-line argument parsing for gws auth setup to use the clap crate, replacing the manual argument parsing logic. This change aims to correctly handle --help and --version flags, preventing the setup wizard from launching when users only request usage information. The parse_setup_args function now returns a Result to indicate successful parsing or an early exit handled by clap. However, a review comment points out a flaw where all clap parsing errors, including invalid arguments, are currently treated as clean exits, resulting in a success exit code (0) instead of an error. The reviewer suggests distinguishing between clean exits (for help/version) and actual validation errors by modifying the return type of parse_setup_args and adjusting its error handling, along with corresponding updates to run_setup and the tests.
Change parse_setup_args return type from Result<SetupOptions, ()> to Result<Option<SetupOptions>, GwsError> so that: - Ok(Some(opts)) = successful parse - Ok(None) = --help/--version displayed (clean exit, code 0) - Err(GwsError) = invalid flags (error exit, non-zero code)
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the argument parsing for gws auth setup to use the clap crate. This change ensures that --help and -h flags are handled correctly, preventing the setup wizard from launching when users only request usage information. The parse_setup_args function now returns a Result<Option<SetupOptions>, GwsError>, allowing for clean exits when help is displayed and proper error handling for invalid arguments. Tests have been updated and expanded to cover these new behaviors. A review comment suggests handling the result of e.print() to prevent silent failures if printing help messages encounters an io::Error.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request refactors the argument parsing for the gws auth setup command to use the clap crate. This change improves argument handling, particularly for --help and unknown arguments, preventing accidental project creation when users only intend to view usage information. The parse_setup_args function now returns a Result<Option<SetupOptions>, GwsError>, allowing for clean exits when help is displayed and proper error handling for invalid arguments. Corresponding updates were made to run_setup and several unit tests, with new tests added to cover the clap-based behavior and an old test removed as it's no longer applicable. I have no feedback to provide.
Summary
Handle
--help/-hingws auth setupbefore launching the setup wizard. Previously, runninggws auth setup --helpwould start the full interactive setup flow (which requiresgcloud), confusing users who just wanted usage information.Fixes #280
Changes
--help/-hat the top ofrun_setup(), beforeparse_setup_args()and wizard initializationgws auth --help)Ok(())immediately — no gcloud dependencyChecklist
AGENTS.mdguidelinescargo fmt --allcargo clippy -- -D warningsand resolved all warnings