fix view always return error

This commit is contained in:
Linh Vo 2017-05-15 13:33:44 -05:00
parent b635bdf970
commit 384329bc91
2 changed files with 19 additions and 2 deletions

View file

@ -394,7 +394,15 @@ func (c *Client) ExportCSV(ctx context.Context, index, frame, view string, slice
return ErrIndexRequired
} else if frame == "" {
return ErrFrameRequired
} else if view != ViewInverse || view != ViewStandard {
}
foundView := false
for _, v := range []string{ViewInverse, ViewStandard} {
if view == v {
foundView = true
break
}
}
if foundView == false {
return ErrInvalidView
}

View file

@ -49,13 +49,22 @@ func NewExportCommand(stdin io.Reader, stdout, stderr io.Writer) *ExportCommand
// Run executes the export.
func (cmd *ExportCommand) Run(ctx context.Context) error {
logger := log.New(cmd.Stderr, "", log.LstdFlags)
foundView := false
// Validate arguments.
if cmd.Index == "" {
return pilosa.ErrIndexRequired
} else if cmd.Frame == "" {
return pilosa.ErrFrameRequired
} else if cmd.View != pilosa.ViewStandard || cmd.View != pilosa.ViewInverse {
}
for _, v := range []string{pilosa.ViewInverse, pilosa.ViewStandard} {
if cmd.View == v {
foundView = true
break
}
}
if foundView == false {
return pilosa.ErrInvalidView
}