databricks-cli/internal
Andrew Nester 9cf0e0db24
Correctly set ExactArgs if generated command has positional arguments (#488)
## Changes
Some of the command such as `databricks alerts create` require
positional arguments which are not primitive.

Since these arguments are required, we should correctly set ExactArgs
for such commands

Fixes #367 

## Tests
Running `databricks alerts create`

Before
```
andrew.nester@HFW9Y94129 cli % ./cli alerts create                     
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/databricks/bricks/cmd/workspace/alerts.glob..func1(0x22a1280?, {0x2321638, 0x0, 0x0?})
	github.com/databricks/bricks/cmd/workspace/alerts/alerts.go:57 +0x355
github.com/spf13/cobra.(*Command).execute(0x22a1280, {0x2321638, 0x0, 0x0})
	github.com/spf13/cobra@v1.7.0/command.go:940 +0x862
github.com/spf13/cobra.(*Command).ExecuteC(0x22a0700)
	github.com/spf13/cobra@v1.7.0/command.go:1068 +0x3bd
github.com/spf13/cobra.(*Command).ExecuteContextC(...)
	github.com/spf13/cobra@v1.7.0/command.go:1001
github.com/databricks/bricks/cmd/root.Execute()
	github.com/databricks/bricks/cmd/root/root.go:80 +0x6a
main.main()
	github.com/databricks/bricks/main.go:18 +0x17                                           

```

After
```
andrew.nester@HFW9Y94129 cli % ./cli alerts create                                                                
Error: provide command input in JSON format by specifying --json option
```
Acceptance test
```
=== RUN   TestAccAlertsCreateErrWhenNoArguments
    alerts_test.go:10: gcp
    helpers.go:147: Error running command: provide command input in JSON format by specifying --json option
--- PASS: TestAccAlertsCreateErrWhenNoArguments (1.99s)
PASS
```
2023-06-16 12:15:25 +00:00
..
build Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
testdata/import_dir Add workspace import-dir command (#456) 2023-06-12 21:03:46 +02:00
alerts_test.go Correctly set ExactArgs if generated command has positional arguments (#488) 2023-06-16 12:15:25 +00:00
api_test.go Rename bricks -> databricks (#389) 2023-05-16 18:35:39 +02:00
clusters_test.go Do not generate prompts for certain commands (#438) 2023-06-05 19:38:45 +02:00
filer_test.go Add workspace import-dir command (#456) 2023-06-12 21:03:46 +02:00
fs_cat_test.go Add fs cat command for dbfs files (#430) 2023-06-06 01:16:23 +02:00
fs_ls_test.go Add fs ls command for dbfs (#429) 2023-06-05 17:41:30 +02:00
helpers.go Restore flags to original values on test completion (#470) 2023-06-14 14:53:27 +02:00
locker_test.go Fix locker integration test (#417) 2023-06-01 09:38:03 +02:00
mkdir_test.go Add fs mkdirs command for dbfs (#432) 2023-06-12 14:05:56 +02:00
rm_test.go Add fs rm command for dbfs (#433) 2023-06-05 23:21:47 +00:00
secrets_test.go Do not prompt for List methods (#411) 2023-05-26 16:02:53 +02:00
sync_test.go Add directory tracking to sync (#425) 2023-06-12 11:44:00 +00:00
version_test.go Use cmdio in version command for `--output` flag (#419) 2023-06-01 12:03:22 +02:00
workspace_test.go Fix deprecation notice for io/ioutil (#477) 2023-06-15 10:38:30 +00:00