Skip to content

Commit

Permalink
cmdr: added package level funcs - Parsed/ParsedLastCmd/....
Browse files Browse the repository at this point in the history
  • Loading branch information
hedzr committed Oct 21, 2024
1 parent c6d7a91 commit d09d50b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cmdr.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,23 @@ func New(opts ...cli.Opt) cli.App {
// Generally it's a unique instance in one system.
//
// It's available once New() / Exec() called, else nil.
//
// App returns a cli.Runner instance, which is different with builder.App.
func App() cli.Runner { return worker.UniqueWorker() }

func AppName() string { return App().Name() } // the app's name
func AppVersion() string { return App().Version() } // the app's version
func AppDescription() string { return App().Root().Desc() } // the app's short description
func AppDescriptionLong() string { return App().Root().DescLong() } // the app's long description

// CmdLines returns the whole command-line as space-separated slice.
func CmdLines() []string { return worker.UniqueWorker().Args() }

func Parsed() bool { return App().ParsedState() != nil } // is parsed ok?
func ParsedLastCmd() cli.Cmd { return App().ParsedState().LastCmd() } // the parsed last command
func ParsedCommands() []cli.Cmd { return App().ParsedState().MatchedCommands() } // the parsed commands
func ParsedPositionalArgs() []string { return App().ParsedState().PositionalArgs() } // the rest positional args

// func Parsed() bool { return worker.UniqueWorker(). }

// Store returns the KVStore associated with current App().
Expand Down

0 comments on commit d09d50b

Please sign in to comment.