Skip to content

feat: CLI parameters#3

Merged
murfffi merged 1 commit intomainfrom
feat/cliparams
Mar 21, 2025
Merged

feat: CLI parameters#3
murfffi merged 1 commit intomainfrom
feat/cliparams

Conversation

@murfffi
Copy link
Owner

@murfffi murfffi commented Mar 21, 2025

Allow configuring what to download with CLI parameters.

Allow configuring what to download with CLI parameters.
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.

Hello @murfffi, 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!

Summary of Changes

This pull request introduces command-line parameters to configure the download behavior of the getaduck tool. It allows users to specify the type of binary (lib or cli), version, OS, and architecture to download via command-line flags. This enhances the tool's flexibility and usability by enabling users to tailor downloads to their specific needs without modifying the default configuration.

Highlights

  • CLI Parameterization: The core change involves adding command-line flags for specifying the binary type, version, OS, and architecture. This is achieved using the flag package and a custom enumflag package for handling the binary type selection.
  • Enum Flag Implementation: A new enumflag package is introduced, adapted from creachadair/goflags, to provide a type-safe way to handle enumerated flag values, specifically for the binary type (lib or cli).
  • Test Updates: The existing download test is updated to skip execution in short mode, as it involves downloading from GitHub. A new end-to-end test is added in shell/run_test.go to verify the CLI functionality.
  • Main Function Update: The main function is modified to use shell.RunArgs instead of shell.Run, passing in the command-line arguments and handling potential errors during execution.

Changelog

Click here to see the changelog
  • download/download_test.go
    • The test TestDo is modified to skip when running in short mode.
    • The test TestDo is modified to run in a subtest called default lib.
    • A comment is added to indicate that CLI is tested e2e in shell/run_test.go
  • internal/enumflag/enumflag.go
    • A new package enumflag is added, adapted from creachadair/goflags, to handle enumerated flag values.
    • The package defines a Value type and associated methods for creating and manipulating enumerated flag values.
  • internal/enumflag/enumflag_test.go
    • A new test file enumflag_test.go is added to test the functionality of the enumflag package.
    • The test file includes a TestFlagBits function that tests the basic functionality of the Value type.
  • main.go
    • The main function is updated to use shell.RunArgs instead of shell.Run.
    • Error handling is added to the main function to log fatal errors returned by shell.RunArgs.
  • shell/run.go
    • The Run function is renamed to RunArgs and modified to accept command-line arguments and an error handling strategy.
    • A new parseSpec function is added to parse the command-line arguments and create a download.Spec object.
    • The parseSpec function uses the flag package and the new enumflag package to parse the command-line arguments.
    • The RunArgs function now returns an error value.
  • shell/run_test.go
    • A new test file run_test.go is added to test the functionality of the shell package.
    • The test file includes a TestRunArgs function that tests the RunArgs function with the cli type.
    • The test file includes a TestParseSpec function that tests the parseSpec function with the version flag.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 is currently in preview and 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 to provide feedback.

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.


Did you know?

The first computer 'bug' was a literal moth found trapped in a relay of the Harvard Mark II computer in 1947.

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.

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 CLI parameters to configure the download of DuckDB binaries, enhancing the tool's flexibility. The changes include a new enumflag package for handling enumerated flag values and modifications to the shell package to parse command-line arguments. Overall, the changes seem well-structured and address the intended functionality.

Summary of Findings

  • Error Handling: The error handling in RunArgs and parseSpec functions is adequate, but consider adding more context to the error messages for better debugging.
  • Test Coverage: The test coverage for the new CLI parameters is good, but consider adding more test cases to cover different combinations of parameters and edge cases.
  • Code Readability: The code is generally readable, but adding comments to explain the purpose of certain code blocks, especially in the parseSpec function, would improve maintainability.

Merge Readiness

The pull request is almost ready for merging. The introduction of CLI parameters is a valuable addition. Before merging, I recommend addressing the error handling and test coverage suggestions to ensure robustness. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging.

@murfffi murfffi merged commit c135b0f into main Mar 21, 2025
6 checks passed
@murfffi murfffi deleted the feat/cliparams branch March 21, 2025 16:48
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