cmd/ipfs2: Added comments to explain purpose of CLI root
Matt Bell committed
Nov 12, 2014 at 19:13 UTC
2fd8f39c65831af799a11655660819d4c17679f5
1 file changed
+7
-2
cmd/ipfs2/ipfs.go
+7
-2
@@ -5,12 +5,17 @@ import (
5
commands "github.com/jbenet/go-ipfs/core/commands2"
6
)
7
8
+// This is the CLI root, used for executing commands accessible to CLI clients.
9
+// Some subcommands (like 'ipfs daemon' or 'ipfs init') are only accessible here,
10
+// and can't be called through the HTTP API.
11
var Root = &cmds.Command{
12
Options: commands.Root.Options,
13
Helptext: commands.Root.Helptext,
14
}
15
13
-var rootSubcommands = map[string]*cmds.Command{
16
+// Commands in localCommands should always be run locally (even if daemon is running).
17
+// They can override subcommands in commands.Root by defining a subcommand with the same name.
18
+var localCommands = map[string]*cmds.Command{
19
"daemon": daemonCmd, // TODO name
20
"init": initCmd, // TODO name
21
"tour": cmdTour,
@@ -20,7 +25,7 @@ var rootSubcommands = map[string]*cmds.Command{
25
func init() {
26
// setting here instead of in literal to prevent initialization loop
27
// (some commands make references to Root)
23
- Root.Subcommands = rootSubcommands
28
+ Root.Subcommands = localCommands
29
30
// copy all subcommands from commands.Root into this root (if they aren't already present)
31
for k, v := range commands.Root.Subcommands {