From d09d50bb07c4dc63e6b78b6b9893b0a93fa91d20 Mon Sep 17 00:00:00 2001 From: Hedzr Yeh Date: Tue, 22 Oct 2024 07:22:27 +0800 Subject: [PATCH] cmdr: added package level funcs - Parsed/ParsedLastCmd/.... --- cmdr.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmdr.go b/cmdr.go index c459f41..5b5e1b7 100644 --- a/cmdr.go +++ b/cmdr.go @@ -82,6 +82,8 @@ 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 @@ -89,8 +91,14 @@ func AppVersion() string { return App().Version() } // the app's 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().