diff --git a/client.go b/client.go index 22ea7d59c..323eef9c3 100644 --- a/client.go +++ b/client.go @@ -394,8 +394,8 @@ func (c *Client) ExportCSV(ctx context.Context, index, frame, view string, slice return ErrIndexRequired } else if frame == "" { return ErrFrameRequired - } else if view == "" { - view = ViewStandard + } else if view != ViewInverse || view != ViewStandard { + return ErrInvalidView } // Retrieve a list of nodes that own the slice. diff --git a/cmd/export.go b/cmd/export.go index 3572ffb7c..e55f84e59 100644 --- a/cmd/export.go +++ b/cmd/export.go @@ -51,9 +51,9 @@ The file does not contain any headers. flags := exportCmd.Flags() flags.StringVarP(&Exporter.Host, "host", "", "localhost:10101", "host:port of Pilosa.") - flags.StringVarP(&Exporter.Index, "index", "i", "", "Pilosa index to export into.") - flags.StringVarP(&Exporter.Frame, "frame", "f", "", "Frame to export into.") - flags.StringVarP(&Exporter.View, "view", "v", "", "View to export into - default standard") + flags.StringVarP(&Exporter.Index, "index", "i", "", "Pilosa index to export") + flags.StringVarP(&Exporter.Frame, "frame", "f", "", "Frame to export") + flags.StringVarP(&Exporter.View, "view", "v", "standard", "View to export - default standard") flags.StringVarP(&Exporter.Path, "output-file", "o", "", "File to write export to - default stdout") return exportCmd diff --git a/cmd/export_test.go b/cmd/export_test.go index 2b30116c6..2d01cf4d6 100644 --- a/cmd/export_test.go +++ b/cmd/export_test.go @@ -44,6 +44,7 @@ frame = "f1" v.Check(cmd.Exporter.Host, "localhost:12345") v.Check(cmd.Exporter.Index, "myindex") v.Check(cmd.Exporter.Frame, "f1") + v.Check(cmd.Exporter.View, "standard") v.Check(cmd.Exporter.Path, "/somefile") return v.Error() }, @@ -51,3 +52,10 @@ frame = "f1" } executeDry(t, tests) } + +func TestExportInvalidView(t *testing.T) { + output, err := ExecNewRootCommand(t, "export", "-i", "foo", "-f", "bar", "-v", "test") + if !strings.Contains(err.Error(), "invalid view") { + t.Fatalf("Command 'export' with invalid view should error but: err: '%v', output: '%v'", err, output) + } +} diff --git a/ctl/export.go b/ctl/export.go index 3ad665551..8b2d6cd35 100644 --- a/ctl/export.go +++ b/ctl/export.go @@ -55,8 +55,8 @@ func (cmd *ExportCommand) Run(ctx context.Context) error { return pilosa.ErrIndexRequired } else if cmd.Frame == "" { return pilosa.ErrFrameRequired - } else if cmd.View == "" { - cmd.View = pilosa.ViewStandard + } else if cmd.View != pilosa.ViewStandard || cmd.View != pilosa.ViewInverse { + return pilosa.ErrInvalidView } // Use output file, if specified.