mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 23:53:19 +08:00
cmd/ipfs2: Added comments to explain purpose of CLI root
This commit is contained in:

committed by
Juan Batiz-Benet

parent
1342575d24
commit
2fd8f39c65
@ -5,12 +5,17 @@ import (
|
|||||||
commands "github.com/jbenet/go-ipfs/core/commands2"
|
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{
|
var Root = &cmds.Command{
|
||||||
Options: commands.Root.Options,
|
Options: commands.Root.Options,
|
||||||
Helptext: commands.Root.Helptext,
|
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
|
"daemon": daemonCmd, // TODO name
|
||||||
"init": initCmd, // TODO name
|
"init": initCmd, // TODO name
|
||||||
"tour": cmdTour,
|
"tour": cmdTour,
|
||||||
@ -20,7 +25,7 @@ var rootSubcommands = map[string]*cmds.Command{
|
|||||||
func init() {
|
func init() {
|
||||||
// setting here instead of in literal to prevent initialization loop
|
// setting here instead of in literal to prevent initialization loop
|
||||||
// (some commands make references to Root)
|
// (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)
|
// copy all subcommands from commands.Root into this root (if they aren't already present)
|
||||||
for k, v := range commands.Root.Subcommands {
|
for k, v := range commands.Root.Subcommands {
|
||||||
|
Reference in New Issue
Block a user