Skip to content

Migrate CLI from go-flags to Kong - #51

Merged
apstndb merged 5 commits into
mainfrom
feat/kong-cli
Jun 27, 2026
Merged

apstndb merged 5 commits into
mainfrom
feat/kong-cli

Conversation

@apstndb

@apstndb apstndb commented Jun 27, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Replace go-flags with Kong for CLI parsing and help output.
  • Preserve existing flags, env vars, positional database arg, and --param-file integration.

Dependencies

Merge after #49 and #50, then rebase this branch onto main so the diff is Kong-only.

Test plan

  • go test ./...
  • Verify --help and env var binding

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

Copy link
Copy Markdown

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 migrates the CLI argument parsing library from go-flags to kong and introduces support for loading query parameters from a YAML or JSON file via a new --param-file flag. It also replaces the go-spannulls dependency with spanvalue/gcvctor for constructing null values. Feedback on the changes suggests removing unsupported query modes (WITH_STATS and WITH_PLAN_AND_STATS) from the CLI options, as they are not valid in the Spanner gRPC API and will silently fall back to NORMAL mode.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go Resolved
Preserve existing flags, env vars, and --param-file integration while switching to Kong for parsing and help output.

Co-authored-by: Cursor <cursoragent@cursor.com>
@apstndb

apstndb commented Jun 27, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 migrates the command-line argument parsing library from go-flags to kong. It updates the option struct tags, replaces the map-based parameter parsing with a slice-based manual parser (ParseParamFlags), and updates the main function to use the new parser. A review comment points out that the migration removed the error and help-printing logic on flag parsing failures, which would cause the application to exit silently without feedback. A suggestion is provided to restore this behavior using a deferred block.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go Resolved
Print parse/validation errors to stderr and show Kong usage help, matching go-flags behavior.

Co-authored-by: Cursor <cursoragent@cursor.com>
@apstndb

apstndb commented Jun 27, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 replaces the go-flags CLI parsing library with kong. It updates the command-line options struct tags, introduces a new helper function ParseParamFlags to parse parameter flags from a slice of strings, and adds corresponding unit tests. Feedback on the changes highlights that the errors.As(err, &parseErr) check in the deferred error handler is unreachable dead code, as Kong's parser exits the program on parsing errors, and subsequent validation errors would trigger the preceding ctx != nil check.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go Resolved
Capture parseErr.Context before return so defer only needs ctx for usage output.

Co-authored-by: Cursor <cursoragent@cursor.com>
@apstndb

apstndb commented Jun 27, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 replaces the go-flags command-line parsing library with github.com/alecthomas/kong. It refactors the options struct and validation logic to use Kong's declarative tags and adds helper functions to parse parameter flags. The review feedback suggests leveraging more of Kong's built-in features, such as the xor tag for declaring mutually exclusive flags (for SQL options, filter options, and timestamp bounds), using the group tag to preserve help output organization, and writing usage information to standard error on failure instead of standard output.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go Resolved
Comment thread main.go Resolved
Comment thread main.go Resolved
Comment thread main.go Resolved
Comment thread main.go Resolved
Declare mutually exclusive flags with xor tags, restore Timestamp Bound help group, and print usage to stderr on failure.

Co-authored-by: Cursor <cursoragent@cursor.com>
@apstndb

apstndb commented Jun 27, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 migrates the CLI argument parsing library from go-flags to kong. This involves refactoring the option structures, removing manual exclusivity checks now handled natively by kong, and introducing a new ParseParamFlags helper to parse repeated parameter flags. Feedback is provided to refactor the flag processing and validation logic in main.go so that the full command usage is not unnecessarily printed for simple validation errors.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread main.go Resolved
Use xor+required for SQL source, ExplicitGroups for timestamp help, print full usage only on parse errors, and guard read-timestamp parsing.

Co-authored-by: Cursor <cursoragent@cursor.com>
@apstndb

apstndb commented Jun 27, 2026

Copy link
Copy Markdown
Owner Author

/gemini review

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

Copy link
Copy Markdown

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 replaces the github.com/jessevdk/go-flags library with github.com/alecthomas/kong for command-line argument parsing. The opts struct and flag processing logic in main.go have been refactored to use Kong's tagging system, which simplifies manual validation for exclusive and required flags. Additionally, a new helper function ParseParamFlags and its corresponding tests have been introduced in the params package to handle repeated parameter flags. There are no review comments, and we have no further feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@apstndb
apstndb merged commit 62f0312 into main Jun 27, 2026
2 checks passed
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