Skip to content

Add Regsiter, which allows go packages to define their own command line args#291

Merged
alexflint merged 3 commits intomasterfrom
register
Oct 7, 2025
Merged

Add Regsiter, which allows go packages to define their own command line args#291
alexflint merged 3 commits intomasterfrom
register

Conversation

@alexflint
Copy link
Copy Markdown
Owner

Add Regsiter, which registers a struct containing command line arguments for inclusion in all future calls to arg.Parse or arg.MustParse. This allows you to define command line arguments per-package like this:

        package foo

        import "github.com/alexflint/go-arg"

        var args struct {
        	CacheSize int `arg:"--foo-cache-size"`
        }

        func init() {
        	args.Register(&argsFoo)
        }

Thanks jcarr!

@alexflint alexflint merged commit db36505 into master Oct 7, 2025
3 checks passed
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.

1 participant