Commit bb8d4ebd authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

cmds2: cmdDetailsMap

parent ef0826ac
......@@ -13,13 +13,16 @@ var Root = &cmds.Command{
Helptext: commands.Root.Helptext,
}
// commandsClientCmd is the "ipfs commands" command for local cli
var commandsClientCmd = commands.CommandsCmd(Root)
// 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,
"commands": commands.CommandsCmd(Root),
"daemon": daemonCmd,
"init": initCmd,
"tour": tourCmd,
"commands": commandsClientCmd,
}
var localMap = make(map[*cmds.Command]bool)
......@@ -45,3 +48,24 @@ func isLocal(cmd *cmds.Command) bool {
_, found := localMap[cmd]
return found
}
type cmdDetails struct {
cannotRunOnClient bool
cannotRunOnDaemon bool
doesNotUseRepo bool
}
// "What is this madness!?" you ask. Our commands have the unfortunate problem of
// not being able to run on all the same contexts. This map describes these
// properties so that other code can make decisions about whether to invoke a
// command or return an error to the user.
var cmdDetailsMap = map[*cmds.Command]cmdDetails{
initCmd: cmdDetails{cannotRunOnDaemon: true, doesNotUseRepo: true},
daemonCmd: cmdDetails{cannotRunOnDaemon: true},
commandsClientCmd: cmdDetails{doesNotUseRepo: true},
commands.CommandsDaemonCmd: cmdDetails{doesNotUseRepo: true},
commands.DiagCmd: cmdDetails{cannotRunOnClient: true},
commands.VersionCmd: cmdDetails{doesNotUseRepo: true},
commands.UpdateCmd: cmdDetails{cannotRunOnDaemon: true},
commands.LogCmd: cmdDetails{cannotRunOnClient: true},
}
......@@ -13,7 +13,7 @@ import (
tour "github.com/jbenet/go-ipfs/tour"
)
var cmdTour = &cmds.Command{
var tourCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "An introduction to IPFS",
ShortDescription: `
......
......@@ -37,9 +37,9 @@ Running 'ipfs bootstrap' with no arguments will run 'ipfs bootstrap list'.
Type: bootstrapListCmd.Type,
Subcommands: map[string]*cmds.Command{
"list": bootstrapListCmd,
"add": bootstrapAddCmd,
"rm": bootstrapRemoveCmd,
"list": bootstrapListCmd,
"add": bootstrapAddCmd,
"rm": bootstrapRemoveCmd,
},
}
......
......@@ -28,7 +28,7 @@ type DiagnosticOutput struct {
Peers []DiagnosticPeer
}
var diagCmd = &cmds.Command{
var DiagCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Generates diagnostic reports",
},
......
......@@ -13,7 +13,7 @@ import (
// we convert it at this step.
var logAllKeyword = "all"
var logCmd = &cmds.Command{
var LogCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Change the logging level",
ShortDescription: `
......
......@@ -51,21 +51,24 @@ Plumbing commands:
},
}
// commandsDaemonCmd is the "ipfs commands" command for daemon
var CommandsDaemonCmd = CommandsCmd(Root)
var rootSubcommands = map[string]*cmds.Command{
"cat": catCmd,
"ls": lsCmd,
"commands": CommandsCmd(Root),
"commands": CommandsDaemonCmd,
"name": nameCmd,
"add": addCmd,
"log": logCmd,
"diag": diagCmd,
"log": LogCmd,
"diag": DiagCmd,
"pin": pinCmd,
"version": versionCmd,
"version": VersionCmd,
"config": configCmd,
"bootstrap": bootstrapCmd,
"mount": mountCmd,
"block": blockCmd,
"update": updateCmd,
"update": UpdateCmd,
"object": objectCmd,
"refs": refsCmd,
}
......
......@@ -14,7 +14,7 @@ type UpdateOutput struct {
NewVersion string
}
var updateCmd = &cmds.Command{
var UpdateCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Downloads and installs updates for IPFS",
ShortDescription: "ipfs update is a utility command used to check for updates and apply them.",
......
......@@ -9,7 +9,7 @@ type VersionOutput struct {
Version string
}
var versionCmd = &cmds.Command{
var VersionCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Outputs the current version of IPFS",
ShortDescription: "Returns the version number of IPFS and exits.",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment