ipfs.go 1.15 KB
Newer Older
1 2 3 4 5 6 7
package main

import (
	cmds "github.com/jbenet/go-ipfs/commands"
	commands "github.com/jbenet/go-ipfs/core/commands2"
)

8 9 10
// 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.
11
var Root = &cmds.Command{
12 13
	Options:  commands.Root.Options,
	Helptext: commands.Root.Helptext,
14 15
}

16 17 18
// 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{
19 20 21 22
	"daemon":   daemonCmd, // TODO name
	"init":     initCmd,   // TODO name
	"tour":     cmdTour,
	"commands": commands.CommandsCmd(Root),
23 24 25 26 27
}

func init() {
	// setting here instead of in literal to prevent initialization loop
	// (some commands make references to Root)
28
	Root.Subcommands = localCommands
29 30 31 32 33 34 35

	// 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
		}
	}
36
}