-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathargv.go
More file actions
41 lines (34 loc) · 710 Bytes
/
Copy pathargv.go
File metadata and controls
41 lines (34 loc) · 710 Bytes
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
package commander
import "strings"
type _Argv []string
func newArgv(args []string) _Argv {
if args != nil && len(args) > 1 {
return _Argv(args[1:])
}
return _Argv([]string{})
}
func (a _Argv) GetArg(index int) string {
if index >= 0 && index < len(a) {
return a[index]
}
return ""
}
func (a _Argv) GetArgs(offsets ...int) []string {
var offset int = 0
if len(offsets) != 0 {
offset = offsets[0]
}
if len(a) <= offset {
return []string{}
}
if offset < 0 {
offset = 0
}
return a[offset:]
}
func (a _Argv) ArgsString() string {
return strings.Join(a, " ")
}
func (a _Argv) ArgsStringSeparator(sep string, offsets ...int) string {
return strings.Join(a.GetArgs(offsets...), sep)
}