Skip to content

feat(core): autocomplete srn arguments on create commands - #6178

Open
ousamabenyounes wants to merge 1 commit into
scaleway:mainfrom
ousamabenyounes:fix/issue-5807
Open

feat(core): autocomplete srn arguments on create commands#6178
ousamabenyounes wants to merge 1 commit into
scaleway:mainfrom
ousamabenyounes:fix/issue-5807

Conversation

@ousamabenyounes

Copy link
Copy Markdown

The generic argument autocompleter skipped any create-verb argument sharing the command's resource name, which silently disabled completion of srn arguments (e.g. scw annotations binding create srn=<tab>). An srn argument references a foreign, pre-existing resource by its Scaleway Resource Name rather than the resource being created, so it is now exempted from that skip and completed from the resource's list verb.

Test verification (RED → GREEN)

With the fix reverted, the new test fails (RED):

        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,5 +1,2 @@
        	            	-(core.AutocompleteSuggestions) (len=2) {
        	            	- (string) (len=16) "srn=srn:tree:oak",
        	            	- (string) (len=17) "srn=srn:tree:pine"
        	            	-}
        	            	+(core.AutocompleteSuggestions) <nil>
        	            	 
        	Test:       	TestAutocomplete/scw_test_tree_create_srn=
=== RUN   TestAutocomplete/scw_test_tree_create_srn=srn:tree:o
    autocomplete_test.go:228: 
        	Error Trace:	/home/ousama/contribute-work/scaleway__scaleway-cli/core/autocomplete_test.go:142
        	Error:      	Not equal: 
        	            	expected: core.AutocompleteSuggestions{"srn=srn:tree:oak"}
        	            	actual  : core.AutocompleteSuggestions(nil)
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1,4 +1,2 @@
        	            	-(core.AutocompleteSuggestions) (len=1) {
        	            	- (string) (len=16) "srn=srn:tree:oak"
        	            	-}
        	            	+(core.AutocompleteSuggestions) <nil>
        	            	 
        	Test:       	TestAutocomplete/scw_test_tree_create_srn=srn:tree:o
--- FAIL: TestAutocomplete (0.00s)
    --- FAIL: TestAutocomplete/scw_test_tree_create_srn= (0.00s)
    --- FAIL: TestAutocomplete/scw_test_tree_create_srn=srn:tree:o (0.00s)
=== RUN   TestAutocompleteArgs
--- PASS: TestAutocompleteArgs (0.00s)
=== RUN   TestAutocompleteProfiles
--- PASS: TestAutocompleteProfiles (0.00s)
=== RUN   TestAutocompleteDeprecatedCommand
--- PASS: TestAutocompleteDeprecatedCommand (0.00s)
FAIL
FAIL	github.com/scaleway/scaleway-cli/v2/core	0.006s
FAIL

With the fix applied, the test passes (GREEN):

GREEN attempt 1/2 (exit 0)
=== RUN   TestAutocomplete
=== RUN   TestAutocomplete/scw_test_tree_create_srn=
=== RUN   TestAutocomplete/scw_test_tree_create_srn=srn:tree:o
--- PASS: TestAutocomplete (0.00s)
    --- PASS: TestAutocomplete/scw_test_tree_create_srn= (0.00s)
    --- PASS: TestAutocomplete/scw_test_tree_create_srn=srn:tree:o (0.00s)
=== RUN   TestAutocompleteArgs
--- PASS: TestAutocompleteArgs (0.00s)
=== RUN   TestAutocompleteProfiles
--- PASS: TestAutocompleteProfiles (0.00s)
=== RUN   TestAutocompleteDeprecatedCommand
--- PASS: TestAutocompleteDeprecatedCommand (0.00s)
PASS
ok  	github.com/scaleway/scaleway-cli/v2/core	0.006s

Full local suite

Command: export PATH="/home/ousama/.local/share/go-1.26.6/go/bin:$PATH" GOTOOLCHAIN=auto; go build ./... && go test ./core/...

ok  	github.com/scaleway/scaleway-cli/v2/core	(cached)
ok  	github.com/scaleway/scaleway-cli/v2/core/human	(cached)

Fix #5807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for autocompleting SRN in the CLI

1 participant