-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcompletion.go
56 lines (48 loc) · 1.27 KB
/
completion.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
53
54
55
56
// Copyright 2017 Factom Foundation
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"github.com/FactomProject/factom"
"github.com/posener/complete"
)
// predictTxName creates command completions from the tx names in
// factom-walletd. It predicts nothing if there is no wallet running.
var predictTxName = complete.PredictFunc(func(args complete.Args) []string {
txs, err := factom.ListTransactionsTmp()
if err != nil {
return nil
}
s := make([]string, 0)
for _, tx := range txs {
s = append(s, tx.Name)
}
return s
})
// predictAddress creates command completions from the addresses in
// factom-walletd. It predicts nothing if there is not wallet running.
var predictAddress = complete.PredictFunc(func(args complete.Args) []string {
fcs, ecs, err := factom.FetchAddresses()
if err != nil {
return nil
}
s := make([]string, 0)
for _, fc := range fcs {
s = append(s, fc.String())
}
for _, ec := range ecs {
s = append(s, ec.String())
}
return s
})
var predictIdentityKey = complete.PredictFunc(func(args complete.Args) []string {
ks, err := factom.FetchIdentityKeys()
if err != nil {
return nil
}
s := make([]string, 0)
for _, k := range ks {
s = append(s, k.String())
}
return s
})