Skip to content

Allow subparsing via structure types #5

@dustbyte

Description

@dustbyte

If a structure type field responding to a defined interface is present within the arguments structure, this field is therefore considered as an "automatic" subcommand (compared to manual that plays with the stop behavior).

When encountered and if matching the program's arguments, the interface's function is executed when argument parsing is finised and the leftovers are parsed against this structure, and so on recursively (that is, a first level subcommand is not executed when one of its fields also responds this interface).

The substructure must respond the following interface:

type Command interface {
    Launch(parameters interface{}, leftover []string)
}
  • parameters hold a pointer to the root parameters structure.
  • leftover holds a list of remaining positional arguments

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions