Source File
subcommand.go
Belonging Package
github.com/alexflint/go-arg
package argimport// Subcommand returns the user struct for the subcommand selected by// the command line arguments most recently processed by the parser.// The return value is always a pointer to a struct. If no subcommand// was specified then it returns the top-level arguments struct. If// no command line arguments have been processed by this parser then it// returns nil.func ( *Parser) () interface{} {if len(.subcommand) == 0 {return nil}, := .lookupCommand(.subcommand...)if != nil {return nil}return .val(.dest).Interface()}// SubcommandNames returns the sequence of subcommands specified by the// user. If no subcommands were given then it returns an empty slice.func ( *Parser) () []string {return .subcommand}// lookupCommand finds a subcommand based on a sequence of subcommand names. The// first string should be a top-level subcommand, the next should be a child// subcommand of that subcommand, and so on. If no strings are given then the// root command is returned. If no such subcommand exists then an error is// returned.func ( *Parser) ( ...string) (*command, error) {:= .cmdfor , := range {:= findSubcommand(.subcommands, )if == nil {return nil, fmt.Errorf("%q is not a subcommand of %s", , .name)}=}return , nil}
![]() |
The pages are generated with Golds v0.8.2. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |