Skip to content

Add getter for positional argument's value field#13

Open
jhiolo wants to merge 1 commit intothought-machine:masterfrom
jhiolo:add-getter-for-arg
Open

Add getter for positional argument's value field#13
jhiolo wants to merge 1 commit intothought-machine:masterfrom
jhiolo:add-getter-for-arg

Conversation

@jhiolo
Copy link
Copy Markdown

@jhiolo jhiolo commented Jan 19, 2026

I want to retrieve the positional args of a subcommand at the root level and to be able to use it like this:

parser := flags.NewNamedParser("blabla"), flags.HelpFlag)
root := parser.Command

cmdInstall.RegisterCmd(root)

parser.CommandHandler = func(commander flags.Commander, args []string) error {
	for _, arg := range parser.Active.Args() {
		log.Debugf("Positional arg %s", arg.Value())
	}
	return commander.Execute(args)
}

I think the easiest implementation with minimal impact is to use a getter.

@jhiolo jhiolo changed the title Add getter for positional argument's value Add getter for positional argument's value field Jan 19, 2026
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