refactor view validator

This commit is contained in:
Linh Vo 2017-05-15 14:56:47 -05:00
parent 384329bc91
commit 5de9a7d0d0
2 changed files with 2 additions and 19 deletions

View file

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

View file

@ -49,22 +49,13 @@ 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
}
for _, v := range []string{pilosa.ViewInverse, pilosa.ViewStandard} {
if cmd.View == v {
foundView = true
break
}
}
if foundView == false {
} else if !(cmd.View == pilosa.ViewStandard || cmd.View == pilosa.ViewInverse) {
return pilosa.ErrInvalidView
}