Skip to content

Refactor/v2#5

Merged
kooksee merged 2 commits intomainfrom
refactor/v2
Jan 20, 2026
Merged

Refactor/v2#5
kooksee merged 2 commits intomainfrom
refactor/v2

Conversation

@kooksee
Copy link
Contributor

@kooksee kooksee commented Jan 20, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kooksee, 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 delivers a significant maintenance and documentation update for the redant Go CLI framework. It focuses on enhancing the framework's stability and correctness by resolving several critical bugs related to flag handling and argument parsing. Concurrently, the user experience is greatly improved through the addition of comprehensive unit tests and a thorough overhaul of the project documentation, including a new Chinese README and a detailed framework evaluation report.

Highlights

  • Version Update: The project version has been updated from v0.0.4 to v0.0.5.
  • Critical Bug Fixes: Several key issues have been addressed, including correct Int64.Type() return value, prevention of duplicate deprecated flag warnings, proper flag inheritance for child commands, and ensuring Option.Default values are correctly applied.
  • Comprehensive Testing: Extensive unit tests have been added for command execution (command_test.go) and various flag value types (flags_test.go), significantly improving test coverage and reliability.
  • Documentation Enhancement: The README.md has been substantially updated with new features, installation instructions, quick start examples, and detailed sections on value types, middleware, parameter formats, global flags, and testing. A Chinese version (README_CN.md) and a detailed framework evaluation report (docs/EVALUATION.md) have also been added.
  • Code Refinements: The command.go file now includes logic for parent flag inheritance and simplified argument parsing. The handler.go signature was updated for consistency, and option.go now correctly applies default flag values.

🧠 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.

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.

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

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

@kooksee kooksee merged commit af49213 into main Jan 20, 2026
1 check passed
Copy link

@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

The pull request introduces several important fixes and improvements to the Redant CLI framework. Key changes include fixing critical issues related to Int64 type handling and default value application, enhancing flag inheritance logic, and improving the argument parsing mechanism. A significant addition is the comprehensive suite of unit tests for both command execution and flag value types, which greatly improves the robustness and reliability of the framework. The README.md and CHANGELOG.md have been updated to reflect these changes, and a detailed EVALUATION.md report has been added, providing excellent documentation and a clear roadmap for future development.

Comment on lines 103 to +104
func (i Int64) String() string {
return strconv.Itoa(int(i))
return strconv.FormatInt(int64(i), 10)

Choose a reason for hiding this comment

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

critical

The String() method for Int64 was previously using strconv.Itoa(int(i)), which could lead to data loss for large int64 values if int is 32-bit. Changing it to strconv.FormatInt(int64(i), 10) correctly handles the full range of int64 values. This is a critical fix for correctness.

Comment on lines 107 to +108
func (Int64) Type() string {
return "int"
return "int64"

Choose a reason for hiding this comment

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

critical

The Type() method for Int64 was incorrectly returning "int". This fix to return "int64" is crucial for pflag to correctly identify and handle int64 values, as noted in the changelog. This is a critical fix for correctness.

Comment on lines +100 to +103
// Apply default value to the Value before adding the flag
if opt.Default != "" && val != DiscardValue {
_ = val.Set(opt.Default) // Ignore error, will be caught during validation
}

Choose a reason for hiding this comment

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

critical

This change correctly applies the Default value to the Value field before the flag is added to the FlagSet. Previously, pflag.Flag.DefValue only affected the help text, not the actual value. This is a critical fix to ensure default values are properly set and used by the application.

Comment on lines 67 to 70
import (
"context"
"fmt"
"os"
"strings"

Choose a reason for hiding this comment

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

high

The os package is used for os.Stderr and os.Exit in the error handling block, but it has been removed from the import list. Please add "os" back to the import statement.

Suggested change
import (
"context"
"fmt"
"os"
"strings"
import (
"context"
"fmt"
"os"
"strings"
"github.com/pubgo/redant"
)

Comment on lines +167 to 169
if err := rootCmd.Invoke().WithOS().Run(); err != nil {
panic(err)
}

Choose a reason for hiding this comment

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

medium

For consistency with the Command with Options example, it is recommended to use fmt.Fprintln(os.Stderr, err); os.Exit(1) instead of panic(err) for error handling in user-facing examples. This provides a more graceful exit for CLI applications.

Suggested change
if err := rootCmd.Invoke().WithOS().Run(); err != nil {
panic(err)
}
if err := rootCmd.Invoke().WithOS().Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}

Comment on lines +465 to +473
// Add flags from all parent commands to support flag inheritance
// This allows child commands to use flags defined in parent commands
for p := inv.Command.parent; p != nil; p = p.parent {
p.Options.FlagSet(p.Name()).VisitAll(func(f *pflag.Flag) {
if inv.Flags.Lookup(f.Name) == nil {
inv.Flags.AddFlag(f)
}
})
}

Choose a reason for hiding this comment

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

medium

The comment for flag inheritance mentions adding flags from parent commands. While the code correctly adds flags, it might be more robust to also consider if a child command explicitly redefines a flag from a parent. In such cases, the child's definition should take precedence. The current logic adds the parent's flag only if it doesn't already exist in inv.Flags, which is good, but it might be worth adding a note about how conflicts are resolved if a child command defines a flag with the same name as a parent's flag.

@kooksee kooksee deleted the refactor/v2 branch February 4, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant