list: Move incomplete as last argument.

implement args.Head() to handle this case smoothly.
This commit is contained in:
Harshavardhana
2015-11-06 16:17:15 -08:00
parent 9f206f590f
commit 8de841cd69
4 changed files with 17 additions and 6 deletions
+3 -1
View File
@@ -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
View File
@@ -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