Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
bb8d4ebd
Commit
bb8d4ebd
authored
Nov 13, 2014
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmds2: cmdDetailsMap
parent
ef0826ac
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
44 additions
and
17 deletions
+44
-17
cmd/ipfs2/ipfs.go
cmd/ipfs2/ipfs.go
+28
-4
cmd/ipfs2/tour.go
cmd/ipfs2/tour.go
+1
-1
core/commands2/bootstrap.go
core/commands2/bootstrap.go
+3
-3
core/commands2/diag.go
core/commands2/diag.go
+1
-1
core/commands2/log.go
core/commands2/log.go
+1
-1
core/commands2/root.go
core/commands2/root.go
+8
-5
core/commands2/update.go
core/commands2/update.go
+1
-1
core/commands2/version.go
core/commands2/version.go
+1
-1
No files found.
cmd/ipfs2/ipfs.go
View file @
bb8d4ebd
...
...
@@ -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"
:
commands
ClientCmd
,
}
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
},
}
cmd/ipfs2/tour.go
View file @
bb8d4ebd
...
...
@@ -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
:
`
...
...
core/commands2/bootstrap.go
View file @
bb8d4ebd
...
...
@@ -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
,
},
}
...
...
core/commands2/diag.go
View file @
bb8d4ebd
...
...
@@ -28,7 +28,7 @@ type DiagnosticOutput struct {
Peers
[]
DiagnosticPeer
}
var
d
iagCmd
=
&
cmds
.
Command
{
var
D
iagCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Generates diagnostic reports"
,
},
...
...
core/commands2/log.go
View file @
bb8d4ebd
...
...
@@ -13,7 +13,7 @@ import (
// we convert it at this step.
var
logAllKeyword
=
"all"
var
l
ogCmd
=
&
cmds
.
Command
{
var
L
ogCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Change the logging level"
,
ShortDescription
:
`
...
...
core/commands2/root.go
View file @
bb8d4ebd
...
...
@@ -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"
:
Commands
Cmd
(
Root
)
,
"commands"
:
Commands
DaemonCmd
,
"name"
:
nameCmd
,
"add"
:
addCmd
,
"log"
:
l
ogCmd
,
"diag"
:
d
iagCmd
,
"log"
:
L
ogCmd
,
"diag"
:
D
iagCmd
,
"pin"
:
pinCmd
,
"version"
:
v
ersionCmd
,
"version"
:
V
ersionCmd
,
"config"
:
configCmd
,
"bootstrap"
:
bootstrapCmd
,
"mount"
:
mountCmd
,
"block"
:
blockCmd
,
"update"
:
u
pdateCmd
,
"update"
:
U
pdateCmd
,
"object"
:
objectCmd
,
"refs"
:
refsCmd
,
}
...
...
core/commands2/update.go
View file @
bb8d4ebd
...
...
@@ -14,7 +14,7 @@ type UpdateOutput struct {
NewVersion
string
}
var
u
pdateCmd
=
&
cmds
.
Command
{
var
U
pdateCmd
=
&
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."
,
...
...
core/commands2/version.go
View file @
bb8d4ebd
...
...
@@ -9,7 +9,7 @@ type VersionOutput struct {
Version
string
}
var
v
ersionCmd
=
&
cmds
.
Command
{
var
V
ersionCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Outputs the current version of IPFS"
,
ShortDescription
:
"Returns the version number of IPFS and exits."
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment