From 2fd8f39c65831af799a11655660819d4c17679f5 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Wed, 12 Nov 2014 19:13:42 -0800 Subject: [PATCH] cmd/ipfs2: Added comments to explain purpose of CLI root --- cmd/ipfs2/ipfs.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmd/ipfs2/ipfs.go b/cmd/ipfs2/ipfs.go index d2286e408..5eccefd2c 100644 --- a/cmd/ipfs2/ipfs.go +++ b/cmd/ipfs2/ipfs.go @@ -5,12 +5,17 @@ import ( commands "github.com/jbenet/go-ipfs/core/commands2" ) +// This is the CLI root, used for executing commands accessible to CLI clients. +// Some subcommands (like 'ipfs daemon' or 'ipfs init') are only accessible here, +// and can't be called through the HTTP API. var Root = &cmds.Command{ Options: commands.Root.Options, Helptext: commands.Root.Helptext, } -var rootSubcommands = map[string]*cmds.Command{ +// Commands in localCommands should always be run locally (even if daemon is running). +// They can override subcommands in commands.Root by defining a subcommand with the same name. +var localCommands = map[string]*cmds.Command{ "daemon": daemonCmd, // TODO name "init": initCmd, // TODO name "tour": cmdTour, @@ -20,7 +25,7 @@ var rootSubcommands = map[string]*cmds.Command{ func init() { // setting here instead of in literal to prevent initialization loop // (some commands make references to Root) - Root.Subcommands = rootSubcommands + Root.Subcommands = localCommands // copy all subcommands from commands.Root into this root (if they aren't already present) for k, v := range commands.Root.Subcommands {