cmd/ipfs2: Added isLocal function for testing if a command is local only
Matt Bell committed
Nov 12, 2014 at 20:49 UTC
b7b15b8b30eee41c8127f649a0bd1d51e83d6214
1 file changed
+11
cmd/ipfs2/ipfs.go
+11
@@ -21,6 +21,7 @@ var localCommands = map[string]*cmds.Command{
21
"tour": cmdTour,
22
"commands": commands.CommandsCmd(Root),
23
}
24
+var localMap = make(map[*cmds.Command]bool)
25
26
func init() {
27
// setting here instead of in literal to prevent initialization loop
@@ -33,4 +34,14 @@ func init() {
34
Root.Subcommands[k] = v
35
}
36
}
37
+
38
+ for _, v := range localCommands {
39
+ localMap[v] = true
40
+ }
41
+}
42
+
43
+// isLocal returns true if the command should only be run locally (not sent to daemon), otherwise false
44
+func isLocal(cmd *cmds.Command) bool {
45
+ _, found := localMap[cmd]
46
+ return found
47
}