feat: add urfave cli adapter - #14
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Adds a new adapters/ourfave package to generate OpenCLI spec documents from urfave/cli v3 apps, mirroring the existing Cobra adapter pattern.
Changes:
- Introduces
adapters/ourfavewith document generation +__openclihidden command and options. - Adds tests covering basic document generation, flags/args mapping, and command-line building.
- Updates module deps and README with urfave/cli adapter usage.
Reviewed changes
Copilot reviewed 9 out of 37 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| go.work.sum | Adds checksum entries for newly introduced indirect dependencies (test/yaml-related). |
| go.sum | Adds github.com/urfave/cli/v3 checksums. |
| go.mod | Adds urfave/cli/v3 to module requirements (currently marked indirect). |
| examples/code/gencli/run.go | Adds generated runner code for example CLI. |
| examples/code/gencli/params.gen.go | Adds generated argument/flag structs and enum validation helpers. |
| examples/code/gencli/iostreams.gen.go | Adds generated IOStreams/Terminal helpers for example CLI. |
| examples/code/gencli/help.gen.go | Adds generated markdown-based help/usage rendering for example CLI. |
| adapters/ourfave/ourfave.go | Implements urfave/cli v3 → OpenCLI document conversion + __opencli command injection. |
| adapters/ourfave/ourfave_test.go | Adds unit tests for the ourfave adapter behavior. |
| README.md | Documents how to use the new urfave adapter. |
Files not reviewed (27)
- examples/code/gencli/actions.gen.go: Generated file
- examples/code/gencli/cmd_petstore.gen.go: Generated file
- examples/code/gencli/cmd_petstore_list.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_add.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_delete.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_findbystatus.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_findbytags.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_get.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_update.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_updateform.gen.go: Generated file
- examples/code/gencli/cmd_petstore_pet_uploadimage.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store_inventory.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store_order.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store_order_delete.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store_order_get.gen.go: Generated file
- examples/code/gencli/cmd_petstore_store_order_place.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_create.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_createwithlist.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_delete.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_get.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_login.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_logout.gen.go: Generated file
- examples/code/gencli/cmd_petstore_user_update.gen.go: Generated file
- examples/code/gencli/errors.gen.go: Generated file
Comments suppressed due to low confidence (4)
examples/code/gencli/run.go:1
errors.AsTypeis not a Go stdlib API and this code will not compile as written. Useerrors.Aswith a target variable (e.g.,var cliErr *CLIError; if errors.As(err, &cliErr) { ... }).
go.mod:1github.com/urfave/cli/v3is imported directly byadapters/ourfave/ourfave.go, so it should not be marked// indirect. Runninggo mod tidy(or removing the indirect marker) should correct this and keep the module metadata consistent.
examples/code/gencli/help.gen.go:1glamour.WithWordWrap(w-leftColWidth)can become zero or negative when the terminal width is small (or whenTerminalSize()fails and returns an unexpected width), which can cause renderer errors/panics. Clamp the wrap width to a sensible minimum (and/or handle theTerminalSize()error instead of discarding it).
examples/code/gencli/iostreams.gen.go:1- Hard-coding
/dev/ttyis not portable (e.g., Windows) and can also fail in containerized/non-interactive environments. Consider using OS-specific implementations via build tags (or a more defensive fallback strategy) so terminal sizing doesn’t rely on/dev/ttybeing present.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the
adapters/ourfavepackage which provides the ability to generate OpenCLI Specification documents from existing urfave/cli v3 applications. It mirrors the functionality of the ocobra adapter but is tailored to the urfave/cli v3 API.