-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathordered-maps.go
52 lines (43 loc) · 1.09 KB
/
ordered-maps.go
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
package cmdline
type orderedCommandLineMap struct {
values map[string]*command
order []string
}
func newOrderedCommandLineMap() *orderedCommandLineMap {
return &orderedCommandLineMap{
values: make(map[string]*command),
order: make([]string, 0),
}
}
func (m *orderedCommandLineMap) add(name string, cmd *command) {
m.values[name] = cmd
m.order = append(m.order, name)
}
type orderedGlobalOptionMap struct {
values map[string]*globalOption
order []string
}
func newOrderedGlobalOptionMap() *orderedGlobalOptionMap {
return &orderedGlobalOptionMap{
values: make(map[string]*globalOption),
order: make([]string, 0),
}
}
func (m *orderedGlobalOptionMap) add(name string, opt *globalOption) {
m.values[name] = opt
m.order = append(m.order, name)
}
type orderedArgSpecMap struct {
values map[string]*argSpec
order []string
}
func newOrderedArgSpecMap() *orderedArgSpecMap {
return &orderedArgSpecMap{
values: make(map[string]*argSpec),
order: make([]string, 0),
}
}
func (m *orderedArgSpecMap) add(name string, as *argSpec) {
m.values[name] = as
m.order = append(m.order, name)
}