Add urfave/cli v2 binding support - #9
Merged
eliothedeman merged 4 commits intoNov 30, 2025
Conversation
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
deleted the
claude/add-urfave-cli-binding-01E3kccDSeNFG6AbuLjtjvB1
branch
November 30, 2025 01:32
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.
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:
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.