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
f797d135
Commit
f797d135
authored
Nov 12, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands2: Added function to generate a 'commands' command for a root
parent
fd8b1930
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
core/commands2/commands.go
core/commands2/commands.go
+20
-16
core/commands2/root.go
core/commands2/root.go
+1
-1
No files found.
core/commands2/commands.go
View file @
f797d135
...
...
@@ -11,23 +11,27 @@ type Command struct {
Subcommands
[]
Command
}
var
commandsCmd
=
&
cmds
.
Command
{
Description
:
"List all available commands."
,
Help
:
`Lists all available commands (and subcommands) and exits.
`
,
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
root
:=
outputCommand
(
"ipfs"
,
Root
)
return
&
root
,
nil
},
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
s
:=
formatCommand
(
""
,
v
)
return
[]
byte
(
s
),
nil
// CommandsCmd takes in a root command,
// and returns a command that lists the subcommands in that root
func
CommandsCmd
(
root
*
cmds
.
Command
)
*
cmds
.
Command
{
return
&
cmds
.
Command
{
Description
:
"List all available commands."
,
Help
:
`Lists all available commands (and subcommands) and exits.
`
,
Run
:
func
(
req
cmds
.
Request
)
(
interface
{},
error
)
{
root
:=
outputCommand
(
"ipfs"
,
root
)
return
&
root
,
nil
},
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
s
:=
formatCommand
(
""
,
v
)
return
[]
byte
(
s
),
nil
},
},
},
Type
:
&
Command
{},
Type
:
&
Command
{
},
}
}
func
outputCommand
(
name
string
,
cmd
*
cmds
.
Command
)
Command
{
...
...
core/commands2/root.go
View file @
f797d135
...
...
@@ -52,7 +52,7 @@ Plumbing commands:
var
rootSubcommands
=
map
[
string
]
*
cmds
.
Command
{
"cat"
:
catCmd
,
"ls"
:
lsCmd
,
"commands"
:
c
ommandsCmd
,
"commands"
:
C
ommandsCmd
(
Root
)
,
"name"
:
nameCmd
,
"add"
:
addCmd
,
"log"
:
logCmd
,
...
...
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