blob: bfbe4291808046cd457f3ff091620a234e94c4a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
package argvpb
// initializes logging and command line options
import (
"strings"
"go.wit.com/dev/alexflint/arg"
)
/*
This struct can be used with the go-arg package. These
are the generic default command line arguments for the 'GUI' package
*/
var argBash ArgsBash
type ArgsBash struct {
Bash bool `arg:"--bash" help:"generate bash completion"`
}
// returns the name of the executable registered for shell autocomplete
func AppName() string {
return me.ARGNAME
}
// try this struct out (?)
var me *AutoArgs
// this is a work in progress
type AutoArgs struct {
id int // should be unique
hidden bool // don't update the toolkits when it's hidden
Argv func([]string) // the function for shell autocomplete
examples func() string // some examples
appExit func() // app Exit()
buildtime func() (string, string) // some examples
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
autoFunc func(*Argv) // also a function for autocomplete
guiFunc func() error // enables Gui functions
err error // store any errors from argv
pb *Argv
ARGNAME string // a good way to track the name of the binary ?
VERSION string
BUILDTIME string
}
// returns the last command (is blank if the current arg is not blank)
func GetLast(cur string, argv []string) string {
if cur != "''" {
return ""
}
for _, s := range argv {
if strings.HasPrefix(s, "-") {
continue
}
return s
}
return ""
}
|