Skip to content

Add urfave/cli v2 binding support - #9

Merged
eliothedeman merged 4 commits into
masterfrom
claude/add-urfave-cli-binding-01E3kccDSeNFG6AbuLjtjvB1
Nov 30, 2025
Merged

Add urfave/cli v2 binding support#9
eliothedeman merged 4 commits into
masterfrom
claude/add-urfave-cli-binding-01E3kccDSeNFG6AbuLjtjvB1

Conversation

@eliothedeman

Copy link
Copy Markdown
Owner

This commit adds full support for urfave/cli v2 framework alongside the
existing Cobra support. Users can now choose between Cobra and urfave/cli
based on their project needs.

Changes:

  • Add BindUrfave() and MustBindUrfave() functions for urfave/cli v2
  • Add UrfaveCommand interface for accessing cli.Context
  • Support all existing features: flags, positional args, repeated args, subcommands
  • Add comprehensive tests for urfave/cli binding
  • Add example demonstrating urfave/cli usage
  • Update README with urfave/cli documentation
  • Store original target in node for framework-specific handling
  • Use reflection to detect UrfaveCommand signature pattern

The implementation reuses the existing node structure and parsing logic,
only converting to framework-specific types (cli.App/cli.Command) at the
final step. This ensures consistency between Cobra and urfave bindings.

This commit adds full support for urfave/cli v2 framework alongside the
existing Cobra support. Users can now choose between Cobra and urfave/cli
based on their project needs.

Changes:
- Add BindUrfave() and MustBindUrfave() functions for urfave/cli v2
- Add UrfaveCommand interface for accessing cli.Context
- Support all existing features: flags, positional args, repeated args, subcommands
- Add comprehensive tests for urfave/cli binding
- Add example demonstrating urfave/cli usage
- Update README with urfave/cli documentation
- Store original target in node for framework-specific handling
- Use reflection to detect UrfaveCommand signature pattern

The implementation reuses the existing node structure and parsing logic,
only converting to framework-specific types (cli.App/cli.Command) at the
final step. This ensures consistency between Cobra and urfave bindings.
Updated dependencies:
- github.com/spf13/cobra: v1.8.0 → v1.10.1
- github.com/spf13/pflag: v1.0.5 → v1.0.10
- github.com/stretchr/testify: v1.8.4 → v1.11.1
- github.com/xrash/smetrics: v0.0.0-20240521201337 → v0.0.0-20250705151800
- Moved urfave/cli/v2 from indirect to direct dependency

All tests pass successfully with updated dependencies.
No breaking changes detected.
This commit migrates the urfave/cli integration from v2 to v3, incorporating
the latest API changes and improvements.

Key changes:
- Update dependency from github.com/urfave/cli/v2 to v3
- Replace *cli.App with *cli.Command (v3 uses Command for both app and commands)
- Update ActionFunc signature from func(*cli.Context) error to func(context.Context, *cli.Command) error
- Update UrfaveCommand interface to match v3 signature: Run(ctx context.Context, cmd *cli.Command) error
- Access flag values from *cli.Command instead of *cli.Context
- Update Command.Run() calls to use context.Context
- Update all examples and tests to use v3 API
- Update README documentation to reflect v3 usage

Breaking changes from v2:
- BindUrfave now returns *cli.Command instead of *cli.App
- Command.Run() now takes (context.Context, []string) instead of just []string
- UrfaveCommand interface now requires Run(ctx context.Context, cmd *cli.Command) error

All tests pass and examples work correctly with v3.
@eliothedeman
eliothedeman merged commit 1346855 into master Nov 30, 2025
1 check passed
@eliothedeman
eliothedeman deleted the claude/add-urfave-cli-binding-01E3kccDSeNFG6AbuLjtjvB1 branch November 30, 2025 01:32
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