From d46d3688277f407f2a30a5c3d2e6eac3b057f823 Mon Sep 17 00:00:00 2001 From: Jeff Zellner Date: Mon, 15 Jul 2024 12:59:49 -0600 Subject: [PATCH 1/2] error if multiple files are supplied to import command --- foxglove/cmd/import.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/foxglove/cmd/import.go b/foxglove/cmd/import.go index af5833b..64230a1 100644 --- a/foxglove/cmd/import.go +++ b/foxglove/cmd/import.go @@ -64,6 +64,9 @@ func newImportCommand(params *baseParams, commandName string) (*cobra.Command, e if len(args) == 0 { dief("Filename not specified") } + if len(args) > 1 { + dief("Only one filename can be specified") + } filename := args[0] err := executeImport( params.baseURL, From 91489319d86ea73c0b43d778849c448139eefabc Mon Sep 17 00:00:00 2001 From: Jeff Zellner Date: Mon, 15 Jul 2024 14:02:45 -0600 Subject: [PATCH 2/2] use cobra.ExactArgs for import command --- foxglove/cmd/import.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/foxglove/cmd/import.go b/foxglove/cmd/import.go index 64230a1..dab2c9c 100644 --- a/foxglove/cmd/import.go +++ b/foxglove/cmd/import.go @@ -52,6 +52,7 @@ func newImportCommand(params *baseParams, commandName string) (*cobra.Command, e importCmd := &cobra.Command{ Use: fmt.Sprintf("%s [FILE]", commandName), Short: "Import a data file to Foxglove Data Platform", + Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { if edgeRecordingID != "" { err := importFromEdge(params.baseURL, *params.clientID, params.token, params.userAgent, edgeRecordingID) @@ -61,12 +62,6 @@ func newImportCommand(params *baseParams, commandName string) (*cobra.Command, e return } - if len(args) == 0 { - dief("Filename not specified") - } - if len(args) > 1 { - dief("Only one filename can be specified") - } filename := args[0] err := executeImport( params.baseURL,