Skip to content

feat: add urfave cli adapter - #14

Merged
bcdxn merged 2 commits into
mainfrom
feature/urfavecli-fromcmd
Jul 20, 2026
Merged

feat: add urfave cli adapter#14
bcdxn merged 2 commits into
mainfrom
feature/urfavecli-fromcmd

Conversation

@bcdxn

@bcdxn bcdxn commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Add the adapters/ourfave package 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.

@bcdxn
bcdxn requested a review from Copilot July 20, 2026 02:17

Copilot AI 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.

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/ourfave with document generation + __opencli hidden 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.AsType is not a Go stdlib API and this code will not compile as written. Use errors.As with a target variable (e.g., var cliErr *CLIError; if errors.As(err, &cliErr) { ... }).
    go.mod:1
  • github.com/urfave/cli/v3 is imported directly by adapters/ourfave/ourfave.go, so it should not be marked // indirect. Running go mod tidy (or removing the indirect marker) should correct this and keep the module metadata consistent.
    examples/code/gencli/help.gen.go:1
  • glamour.WithWordWrap(w-leftColWidth) can become zero or negative when the terminal width is small (or when TerminalSize() fails and returns an unexpected width), which can cause renderer errors/panics. Clamp the wrap width to a sensible minimum (and/or handle the TerminalSize() error instead of discarding it).
    examples/code/gencli/iostreams.gen.go:1
  • Hard-coding /dev/tty is 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/tty being present.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread adapters/ourfave/ourfave.go Outdated
Comment thread adapters/ourfave/ourfave.go
Comment thread adapters/ourfave/ourfave_test.go Outdated
Comment thread adapters/ourfave/ourfave.go
@bcdxn
bcdxn merged commit 3d53add into main Jul 20, 2026
7 checks passed
@bcdxn
bcdxn deleted the feature/urfavecli-fromcmd branch July 20, 2026 20:14
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.

2 participants