refactor: simplify --exit-code from integer to boolean flag#140
refactor: simplify --exit-code from integer to boolean flag#140
Conversation
The exit_code option was an integer that behaved as a boolean. Simplify to a true boolean flag: --exit-code enables exit code 1 on certificate issues, omitting it always exits 0. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello @jbovet, 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 streamlines the application's exit code handling by converting the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. 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 refactors the --exit-code option from an integer to a boolean, which simplifies its usage. The changes are consistently applied across the configuration handling, main application logic, and tests.
My main feedback is regarding the command-line argument parsing for the new exit_code flag. The current implementation as a simple boolean flag removes the ability for a user to disable the exit code behavior from the CLI if it's enabled in a configuration file. I've suggested changing it to an Option<bool> to restore this functionality and align it with how other similar options are handled in the code.
| #[arg(long, default_value_t = false)] | ||
| exit_code: bool, |
There was a problem hiding this comment.
While changing exit_code to a boolean is a good simplification, making it a simple flag (bool) removes the ability to disable it from the command line if it's enabled in a configuration file. The previous Option<i32> allowed this with --exit-code 0.
To maintain this flexibility and for consistency with other arguments like prometheus, I suggest using Option<bool>. This would allow --exit-code true and --exit-code false, providing clear override capability from the command line.
With this change, you can then simplify the call in load_config.
| #[arg(long, default_value_t = false)] | |
| exit_code: bool, | |
| #[arg(long)] | |
| exit_code: Option<bool>, |
| cli_addresses, | ||
| cli.output.as_ref().map(|o| o.to_string()), | ||
| cli.exit_code, | ||
| if cli.exit_code { Some(true) } else { None }, |
There was a problem hiding this comment.
If you change exit_code in Args to Option<bool> as suggested in my other comment, you can simplify this to pass cli.exit_code directly. This avoids the conditional logic and correctly handles None when the argument is not provided, preserving the configuration file precedence.
| if cli.exit_code { Some(true) } else { None }, | |
| cli.exit_code, |
The exit_code option was an integer that behaved as a boolean.
Simplify to a true boolean flag: --exit-code enables exit code 1
on certificate issues, omitting it always exits 0.
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com