blob: bb45d1c0967a15a736813f8e716c81b5ec1918c7 (
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
|
package complete
type args struct {
all []string
completed []string
beingTyped string
lastCompleted string
}
func newArgs(line []string) args {
completed := removeLast(line)
return args{
all: line[1:],
completed: completed,
beingTyped: last(line),
lastCompleted: last(completed),
}
}
func (a args) from(i int) args {
a.all = a.all[i:]
a.completed = a.completed[i:]
return a
}
func removeLast(a []string) []string {
if len(a) > 0 {
return a[:len(a)-1]
}
return a
}
func last(args []string) (last string) {
if len(args) > 0 {
last = args[len(args)-1]
}
return
}
|