list: Move incomplete as last argument.
implement args.Head() to handle this case smoothly.
This commit is contained in:
+3
-1
@@ -19,8 +19,10 @@ import (
|
||||
type App struct {
|
||||
// The name of the program. Defaults to os.Args[0]
|
||||
Name string
|
||||
// Description of the program.
|
||||
// Usage of the program.
|
||||
Usage string
|
||||
// Description of the program.
|
||||
Description string
|
||||
// Version of the program
|
||||
Version string
|
||||
// List of commands to execute
|
||||
|
||||
+9
@@ -193,6 +193,15 @@ func (a Args) Tail() Args {
|
||||
return []string{}
|
||||
}
|
||||
|
||||
// Head - Return the rest of the arguments (not the last one)
|
||||
// or else an empty string slice
|
||||
func (a Args) Head() Args {
|
||||
if len(a) == 1 {
|
||||
return a
|
||||
}
|
||||
return []string(a)[:len(a)-1]
|
||||
}
|
||||
|
||||
// Present - Checks if there are any arguments present
|
||||
func (a Args) Present() bool {
|
||||
return len(a) != 0
|
||||
|
||||
Reference in New Issue
Block a user