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
0149f65c
Commit
0149f65c
authored
Nov 03, 2014
by
Matt Bell
Committed by
Juan Batiz-Benet
Nov 04, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commands: Replaced 'Formatter' with 'Marshaller'
parent
068e10cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
10 deletions
+5
-10
commands/command.go
commands/command.go
+3
-4
commands/response.go
commands/response.go
+2
-6
No files found.
commands/command.go
View file @
0149f65c
...
...
@@ -15,10 +15,9 @@ var log = u.Logger("command")
// It reads from the Request, and writes results to the Response.
type
Function
func
(
Response
,
Request
)
//
Formatt
er is a function that takes in a Response, and returns a
human-readable string
//
Marshall
er is a function that takes in a Response, and returns a
marshalled []byte
// (or an error on failure)
// MAYBE_TODO: maybe this should be a io.Reader instead of a string?
type
Formatter
func
(
Response
)
(
string
,
error
)
type
Marshaller
func
(
Response
)
([]
byte
,
error
)
// TODO: check Argument definitions when creating a Command
// (might need to use a Command constructor)
...
...
@@ -33,7 +32,7 @@ type Command struct {
Options
[]
Option
Arguments
[]
Argument
Run
Function
Format
Formatt
er
Format
Marshall
er
Type
interface
{}
Subcommands
map
[
string
]
*
Command
}
...
...
commands/response.go
View file @
0149f65c
...
...
@@ -40,10 +40,6 @@ const (
// TODO: support more encoding types
)
// Marshaller is a function used by coding types.
// TODO this should just be a `coding.Codec`
type
Marshaller
func
(
res
Response
)
([]
byte
,
error
)
var
marshallers
=
map
[
EncodingType
]
Marshaller
{
JSON
:
func
(
res
Response
)
([]
byte
,
error
)
{
if
res
.
Error
()
!=
nil
{
...
...
@@ -63,11 +59,11 @@ var marshallers = map[EncodingType]Marshaller{
return
nil
,
ErrNoFormatter
}
s
,
err
:=
format
(
res
)
byte
s
,
err
:=
format
(
res
)
if
err
!=
nil
{
return
nil
,
err
}
return
[]
byte
(
s
)
,
nil
return
byte
s
,
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