Skip to content

feat: add support for urfave/cli code generation#10

Merged
bcdxn merged 5 commits into
mainfrom
feature/urfavecli
Jul 11, 2026
Merged

feat: add support for urfave/cli code generation#10
bcdxn merged 5 commits into
mainfrom
feature/urfavecli

Conversation

@bcdxn

@bcdxn bcdxn commented Jul 11, 2026

Copy link
Copy Markdown
Owner

Add support for generating CLI boilerplate using the urfave/cli framework, alongside existing support for Cobra and Yargs. Additionally, it fixes the CommandLine field for Cobra-generated commands to avoid duplicate segments.

Urfave/cli framework support:

ocli gen cli \
  --framework urfavecli \
  --out ./scratch/pleasantries/internal \
  ./examples/pleasantires-cli.ocs.yaml

Minor Fixes

  • Fix: Cobra/Yargs help messages duplicated command binary name
  • fix: make make file commands more intuitive

@codecov-commenter

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

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

Adds a new CLI codegen backend for Go’s github.com/urfave/cli/v3, wires it into the ocli gen cli command, and updates generated docs/test fixtures accordingly. This extends OpenCLI’s generator set beyond Cobra (Go) and yargs (Node) while also correcting a Cobra command-line rendering issue that produced duplicated segments (e.g. petstore petstore ...).

Changes:

  • Add URFAVECLI as a supported gen.CLIFramework, including a full urfave/cli generator implementation and templates.
  • Update the CLI app layer + spec/docs to expose urfavecli as a selectable --framework choice.
  • Add golden testdata for the urfave/cli generator and fix Cobra-generated CommandLine strings to avoid duplication.

Reviewed changes

Copilot reviewed 56 out of 73 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
web/public/ocli-docs.js Updates embedded HTML docs output to reflect framework choice changes.
opencli.ocs.yaml Adds urfavecli as a --framework choice in the project’s OpenCLI spec (and updates descriptions).
Makefile Reorders doc generation flags and adds a scratch CLI generation target for manual regression testing.
internal/cli/app/actions.go Extends ocli gen cli --framework mapping to support urfavecli.
internal/cli/app/actions_test.go Updates unsupported-framework test to reflect newly supported urfavecli.
gen/testdata/urfavecli/gencli/run.gen.go Golden output for urfave/cli Run() entrypoint.
gen/testdata/urfavecli/gencli/params.gen.go Golden output for generated args/flags types (urfave/cli).
gen/testdata/urfavecli/gencli/iostreams.gen.go Golden output for generated IOStreams helpers (urfave/cli).
gen/testdata/urfavecli/gencli/help.gen.go Golden output for generated help rendering + urfave template integration.
gen/testdata/urfavecli/gencli/errors.gen.go Golden output for generated error/exit-code helpers (urfave/cli).
gen/testdata/urfavecli/gencli/cmd_petstore.gen.go Golden output for urfave/cli root command.
gen/testdata/urfavecli/gencli/cmd_petstore_user.gen.go Golden output for urfave/cli user command group.
gen/testdata/urfavecli/gencli/cmd_petstore_user_update.gen.go Golden output for urfave/cli user update leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_logout.gen.go Golden output for urfave/cli user logout leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_login.gen.go Golden output for urfave/cli user login leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_get.gen.go Golden output for urfave/cli user get leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_delete.gen.go Golden output for urfave/cli user delete leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_createwithlist.gen.go Golden output for urfave/cli user create-with-list leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_user_create.gen.go Golden output for urfave/cli user create leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_store.gen.go Golden output for urfave/cli store command group.
gen/testdata/urfavecli/gencli/cmd_petstore_store_order.gen.go Golden output for urfave/cli store order command group.
gen/testdata/urfavecli/gencli/cmd_petstore_store_order_place.gen.go Golden output for urfave/cli store order place leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_store_order_get.gen.go Golden output for urfave/cli store order get leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_store_order_delete.gen.go Golden output for urfave/cli store order delete leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_store_inventory.gen.go Golden output for urfave/cli store inventory leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet.gen.go Golden output for urfave/cli pet command group.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_uploadimage.gen.go Golden output for urfave/cli pet upload-image leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_updateform.gen.go Golden output for urfave/cli pet update-form leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_update.gen.go Golden output for urfave/cli pet update leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_get.gen.go Golden output for urfave/cli pet get leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_findbytags.gen.go Golden output for urfave/cli pet find-by-tags leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_findbystatus.gen.go Golden output for urfave/cli pet find-by-status leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_delete.gen.go Golden output for urfave/cli pet delete leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_pet_add.gen.go Golden output for urfave/cli pet add leaf command.
gen/testdata/urfavecli/gencli/cmd_petstore_list.gen.go Golden output for urfave/cli list leaf command.
gen/testdata/urfavecli/gencli/actions.gen.go Golden output for urfave/cli Actions interface.
gen/testdata/cobra/gencli/cmd_petstore.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_update.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_logout.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_login.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_get.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_delete.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_createwithlist.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_user_create.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store_order.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store_order_place.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store_order_get.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store_order_delete.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_store_inventory.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_uploadimage.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_updateform.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_update.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_get.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_findbytags.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_findbystatus.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_delete.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_pet_add.gen.go Updates Cobra golden output for corrected CommandLine.
gen/testdata/cobra/gencli/cmd_petstore_list.gen.go Updates Cobra golden output for corrected CommandLine.
gen/templates/code/urfavecli/gencli/run.tmpl Adds urfave/cli codegen template for the generated entrypoint.
gen/templates/code/urfavecli/gencli/params.tmpl Adds urfave/cli codegen template for args/flags type generation.
gen/templates/code/urfavecli/gencli/iostreams.tmpl Adds urfave/cli codegen template for IOStreams helpers.
gen/templates/code/urfavecli/gencli/help.tmpl Adds urfave/cli codegen template for help rendering customization.
gen/templates/code/urfavecli/gencli/errors.tmpl Adds urfave/cli codegen template for errors/exit codes.
gen/templates/code/urfavecli/gencli/command.tmpl Adds urfave/cli codegen template for command construction.
gen/templates/code/urfavecli/gencli/actions.tmpl Adds urfave/cli codegen template for Actions interface.
gen/cli.go Registers UrfaveCliFramework in the generator switch.
gen/cli_urfave_cli.go Implements the urfave/cli generator backend and template wiring.
gen/cli_test.go Adds golden test coverage for urfave/cli generation.
gen/cli_cobra.go Fixes Cobra CommandLine generation to avoid duplicating the binary name.
docs/opencli.ocs.md Updates the generated markdown docs to include urfavecli as a framework option.
Files not reviewed (17)
  • gen/testdata/cobra/gencli/cmd_petstore.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_list.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_add.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_delete.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_findbystatus.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_findbytags.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_get.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_update.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_updateform.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_pet_uploadimage.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store_inventory.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store_order.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store_order_delete.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store_order_get.gen.go: Generated file
  • gen/testdata/cobra/gencli/cmd_petstore_store_order_place.gen.go: Generated file

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

Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread Makefile Outdated
Comment thread gen/templates/code/urfavecli/gencli/help.tmpl
Comment thread gen/templates/code/urfavecli/gencli/help.tmpl
@bcdxn bcdxn merged commit 611c972 into main Jul 11, 2026
7 checks passed
@bcdxn bcdxn linked an issue Jul 11, 2026 that may be closed by this pull request
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.

[Feature Request]: Support Code Generation for urfave/cli

3 participants