Commit bbef82f4 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

"enc" -> EncShort

parent 4986600e
...@@ -57,7 +57,7 @@ func TestOptionValidation(t *testing.T) { ...@@ -57,7 +57,7 @@ func TestOptionValidation(t *testing.T) {
} }
req = NewEmptyRequest() req = NewEmptyRequest()
req.options["enc"] = "json" req.options[EncShort] = "json"
res = cmd.Call(req) res = cmd.Call(req)
if res.Error != nil { if res.Error != nil {
t.Error("Should have passed") t.Error("Should have passed")
...@@ -110,7 +110,7 @@ func TestRegistration(t *testing.T) { ...@@ -110,7 +110,7 @@ func TestRegistration(t *testing.T) {
&Command{ &Command{
Options: []Option{ Options: []Option{
Option{[]string{"enc"}, String}, Option{[]string{EncShort}, String},
}, },
run: func(req *Request, res *Response) {}, run: func(req *Request, res *Response) {},
}, },
......
...@@ -22,9 +22,15 @@ type Option struct { ...@@ -22,9 +22,15 @@ type Option struct {
//Required bool // whether or not the option must be provided //Required bool // whether or not the option must be provided
} }
// Flag names
const (
EncShort = "enc"
EncLong = "encoding"
)
// options that are used by this package // options that are used by this package
var globalOptions = []Option{ var globalOptions = []Option{
Option{[]string{"enc", "encoding"}, String}, Option{[]string{EncShort, EncLong}, String},
} }
// the above array of Options, wrapped in a Command // the above array of Options, wrapped in a Command
......
...@@ -66,7 +66,7 @@ func (r *Response) Marshal() ([]byte, error) { ...@@ -66,7 +66,7 @@ func (r *Response) Marshal() ([]byte, error) {
return nil, fmt.Errorf("No error or value set, there is nothing to marshal") return nil, fmt.Errorf("No error or value set, there is nothing to marshal")
} }
enc, ok := r.req.Option("enc") enc, ok := r.req.Option(EncShort)
if !ok || enc.(string) == "" { if !ok || enc.(string) == "" {
return nil, fmt.Errorf("No encoding type was specified") return nil, fmt.Errorf("No encoding type was specified")
} }
......
...@@ -30,7 +30,7 @@ func TestMarshalling(t *testing.T) { ...@@ -30,7 +30,7 @@ func TestMarshalling(t *testing.T) {
t.Error("Should have failed (no encoding type specified in request)") t.Error("Should have failed (no encoding type specified in request)")
} }
req.SetOption("enc", JSON) req.SetOption(EncShort, JSON)
req.convertOptions(options) req.convertOptions(options)
bytes, err := res.Marshal() bytes, err := res.Marshal()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment