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
0afd3391
Commit
0afd3391
authored
Nov 03, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 14, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Replaced 'Formatter' with 'Marshaller'
parent
3dd7a9a5
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
14 deletions
+17
-14
core/commands2/add.go
core/commands2/add.go
+4
-3
core/commands2/commands.go
core/commands2/commands.go
+3
-2
core/commands2/log.go
core/commands2/log.go
+1
-1
core/commands2/ls.go
core/commands2/ls.go
+2
-2
core/commands2/publish.go
core/commands2/publish.go
+3
-2
core/commands2/root.go
core/commands2/root.go
+4
-4
No files found.
core/commands2/add.go
View file @
0afd3391
...
@@ -55,17 +55,18 @@ var addCmd = &cmds.Command{
...
@@ -55,17 +55,18 @@ var addCmd = &cmds.Command{
res
.
SetOutput
(
&
AddOutput
{
added
})
res
.
SetOutput
(
&
AddOutput
{
added
})
},
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
AddOutput
)
.
Added
v
:=
res
.
Output
()
.
(
*
AddOutput
)
.
Added
if
len
(
v
)
==
1
{
if
len
(
v
)
==
1
{
return
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
v
[
0
]
.
Hash
),
nil
s
:=
fmt
.
Sprintf
(
"Added object: %s
\n
"
,
v
[
0
]
.
Hash
)
return
[]
byte
(
s
),
nil
}
}
s
:=
fmt
.
Sprintf
(
"Added %v objects:
\n
"
,
len
(
v
))
s
:=
fmt
.
Sprintf
(
"Added %v objects:
\n
"
,
len
(
v
))
for
_
,
obj
:=
range
v
{
for
_
,
obj
:=
range
v
{
s
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
obj
.
Hash
)
s
+=
fmt
.
Sprintf
(
"- %s
\n
"
,
obj
.
Hash
)
}
}
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
},
Type
:
&
AddOutput
{},
Type
:
&
AddOutput
{},
}
}
...
...
core/commands2/commands.go
View file @
0afd3391
...
@@ -18,9 +18,10 @@ var commandsCmd = &cmds.Command{
...
@@ -18,9 +18,10 @@ var commandsCmd = &cmds.Command{
root
:=
outputCommand
(
"ipfs"
,
Root
)
root
:=
outputCommand
(
"ipfs"
,
Root
)
res
.
SetOutput
(
&
root
)
res
.
SetOutput
(
&
root
)
},
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
v
:=
res
.
Output
()
.
(
*
Command
)
return
formatCommand
(
v
,
0
),
nil
s
:=
formatCommand
(
v
,
0
)
return
[]
byte
(
s
),
nil
},
},
Type
:
&
Command
{},
Type
:
&
Command
{},
}
}
...
...
core/commands2/log.go
View file @
0afd3391
...
@@ -23,6 +23,6 @@ var logCmd = &cmds.Command{
...
@@ -23,6 +23,6 @@ var logCmd = &cmds.Command{
s
:=
fmt
.
Sprintf
(
"Changed log level of '%s' to '%s'"
,
args
[
0
],
args
[
1
])
s
:=
fmt
.
Sprintf
(
"Changed log level of '%s' to '%s'"
,
args
[
0
],
args
[
1
])
res
.
SetOutput
(
&
MessageOutput
{
s
})
res
.
SetOutput
(
&
MessageOutput
{
s
})
},
},
Format
:
Message
Formatt
er
,
Format
:
Message
Marshall
er
,
Type
:
&
MessageOutput
{},
Type
:
&
MessageOutput
{},
}
}
core/commands2/ls.go
View file @
0afd3391
...
@@ -52,7 +52,7 @@ var lsCmd = &cmds.Command{
...
@@ -52,7 +52,7 @@ var lsCmd = &cmds.Command{
res
.
SetOutput
(
&
LsOutput
{
output
})
res
.
SetOutput
(
&
LsOutput
{
output
})
},
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
s
:=
""
s
:=
""
output
:=
res
.
Output
()
.
(
*
LsOutput
)
.
Objects
output
:=
res
.
Output
()
.
(
*
LsOutput
)
.
Objects
...
@@ -70,7 +70,7 @@ var lsCmd = &cmds.Command{
...
@@ -70,7 +70,7 @@ var lsCmd = &cmds.Command{
}
}
}
}
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
},
Type
:
&
LsOutput
{},
Type
:
&
LsOutput
{},
}
}
core/commands2/publish.go
View file @
0afd3391
...
@@ -61,9 +61,10 @@ var publishCmd = &cmds.Command{
...
@@ -61,9 +61,10 @@ var publishCmd = &cmds.Command{
Value
:
ref
,
Value
:
ref
,
})
})
},
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
PublishOutput
)
v
:=
res
.
Output
()
.
(
*
PublishOutput
)
return
fmt
.
Sprintf
(
"Published name %s to %s
\n
"
,
v
.
Name
,
v
.
Value
),
nil
s
:=
fmt
.
Sprintf
(
"Published name %s to %s
\n
"
,
v
.
Name
,
v
.
Value
)
return
[]
byte
(
s
),
nil
},
},
Type
:
&
PublishOutput
{},
Type
:
&
PublishOutput
{},
}
}
core/commands2/root.go
View file @
0afd3391
...
@@ -71,11 +71,11 @@ var rootSubcommands = map[string]*cmds.Command{
...
@@ -71,11 +71,11 @@ var rootSubcommands = map[string]*cmds.Command{
log
.
Info
(
"beep"
)
log
.
Info
(
"beep"
)
res
.
SetOutput
(
v
)
res
.
SetOutput
(
v
)
},
},
Format
:
func
(
res
cmds
.
Response
)
(
string
,
error
)
{
Format
:
func
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
v
:=
res
.
Output
()
.
(
*
TestOutput
)
v
:=
res
.
Output
()
.
(
*
TestOutput
)
s
:=
fmt
.
Sprintf
(
"Foo: %s
\n
"
,
v
.
Foo
)
s
:=
fmt
.
Sprintf
(
"Foo: %s
\n
"
,
v
.
Foo
)
s
+=
fmt
.
Sprintf
(
"Bar: %v
\n
"
,
v
.
Bar
)
s
+=
fmt
.
Sprintf
(
"Bar: %v
\n
"
,
v
.
Bar
)
return
s
,
nil
return
[]
byte
(
s
)
,
nil
},
},
Type
:
&
TestOutput
{},
Type
:
&
TestOutput
{},
},
},
...
@@ -120,6 +120,6 @@ type MessageOutput struct {
...
@@ -120,6 +120,6 @@ type MessageOutput struct {
Message
string
Message
string
}
}
func
Message
Formatt
er
(
res
cmds
.
Response
)
(
string
,
error
)
{
func
Message
Marshall
er
(
res
cmds
.
Response
)
(
[]
byte
,
error
)
{
return
res
.
Output
()
.
(
*
MessageOutput
)
.
Message
,
nil
return
[]
byte
(
res
.
Output
()
.
(
*
MessageOutput
)
.
Message
)
,
nil
}
}
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