1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-25 15:08:45 +08:00

cmd/ipfs2: Copy subcommands from core/commands2 root into cmd/ipfs2 root

This commit is contained in:
Matt Bell
2014-11-12 16:46:51 -08:00
committed by Juan Batiz-Benet
parent 53e875e5fc
commit fd8b1930af
2 changed files with 20 additions and 6 deletions

View File

@ -8,9 +8,23 @@ import (
var Root = &cmds.Command{ var Root = &cmds.Command{
Options: commands.Root.Options, Options: commands.Root.Options,
Help: commands.Root.Help, Help: commands.Root.Help,
Subcommands: map[string]*cmds.Command{ }
var rootSubcommands = map[string]*cmds.Command{
"daemon": daemonCmd, // TODO name "daemon": daemonCmd, // TODO name
"init": initCmd, // TODO name "init": initCmd, // TODO name
"tour": cmdTour, "tour": cmdTour,
}, }
func init() {
// setting here instead of in literal to prevent initialization loop
// (some commands make references to Root)
Root.Subcommands = rootSubcommands
// copy all subcommands from commands.Root into this root (if they aren't already present)
for k, v := range commands.Root.Subcommands {
if _, found := Root.Subcommands[k]; !found {
Root.Subcommands[k] = v
}
}
} }

View File

@ -94,7 +94,7 @@ func run() error {
} }
func createRequest(args []string) (cmds.Request, *cmds.Command, error) { func createRequest(args []string) (cmds.Request, *cmds.Command, error) {
req, root, cmd, path, err := cmdsCli.Parse(args, Root, commands.Root) req, root, cmd, path, err := cmdsCli.Parse(args, Root)
// handle parse error (which means the commandline input was wrong, // handle parse error (which means the commandline input was wrong,
// e.g. incorrect number of args, or nonexistent subcommand) // e.g. incorrect number of args, or nonexistent subcommand)