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-unixfs
Commits
53e875e5
Commit
53e875e5
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: Format 'commands' to match original output (re: #317)
parent
4e740f63
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
9 deletions
+7
-9
core/commands2/commands.go
core/commands2/commands.go
+7
-9
No files found.
core/commands2/commands.go
View file @
53e875e5
...
@@ -2,7 +2,6 @@ package commands
...
@@ -2,7 +2,6 @@ package commands
import
(
import
(
"fmt"
"fmt"
"strings"
cmds
"github.com/jbenet/go-ipfs/commands"
cmds
"github.com/jbenet/go-ipfs/commands"
)
)
...
@@ -24,7 +23,7 @@ var commandsCmd = &cmds.Command{
...
@@ -24,7 +23,7 @@ var commandsCmd = &cmds.Command{
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
Marshallers
:
map
[
cmds
.
EncodingType
]
cmds
.
Marshaller
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
([]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
v
:=
res
.
Output
()
.
(
*
Command
)
s
:=
formatCommand
(
v
,
0
)
s
:=
formatCommand
(
""
,
v
)
return
[]
byte
(
s
),
nil
return
[]
byte
(
s
),
nil
},
},
},
},
...
@@ -46,16 +45,15 @@ func outputCommand(name string, cmd *cmds.Command) Command {
...
@@ -46,16 +45,15 @@ func outputCommand(name string, cmd *cmds.Command) Command {
return
output
return
output
}
}
func
formatCommand
(
cmd
*
Command
,
depth
int
)
string
{
func
formatCommand
(
prefix
string
,
cmd
*
Command
)
string
{
var
s
string
if
len
(
prefix
)
>
0
{
prefix
+=
" "
if
depth
>
0
{
indent
:=
strings
.
Repeat
(
" "
,
depth
-
1
)
s
=
fmt
.
Sprintf
(
"%s%s
\n
"
,
indent
,
cmd
.
Name
)
}
}
s
:=
fmt
.
Sprintf
(
"%s%s
\n
"
,
prefix
,
cmd
.
Name
)
prefix
+=
cmd
.
Name
for
_
,
sub
:=
range
cmd
.
Subcommands
{
for
_
,
sub
:=
range
cmd
.
Subcommands
{
s
+=
formatCommand
(
&
sub
,
depth
+
1
)
s
+=
formatCommand
(
prefix
,
&
sub
)
}
}
return
s
return
s
...
...
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