From 7aa4a1ff5f9b061ed19671aac53bf7c272200795 Mon Sep 17 00:00:00 2001 From: Amedeo Palopoli Date: Fri, 19 Jun 2026 15:16:00 +0200 Subject: [PATCH 1/4] =?UTF-8?q?=EF=BB=BFfix(completion):=20complete=20pare?= =?UTF-8?q?nt-ID=20slots=20for=20database=20and=20storage=20sub-resources?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Database family: - completeDBaaSDatabaseID: was returning nil for args[0] (dbaas-id slot); now delegates to completeDBaaSID. Registered on database create and list, which had no ValidArgsFunction. - completeDBaaSUserID: same fix. Registered on user create and list. - completeGrantID: was returning nil for args[0] and args[1]; now delegates to completeDBaaSID ? completeDBaaSDatabaseID in order. Registered on all four grant commands (create, list, get, delete), none of which had ValidArgsFunction. Storage family: - storage backup create (storageBackupCmd): the positional [volume-id] arg had no completion; registered completeBlockStorageID. - storage restore create (storageRestoreCmd): [backup-id] [volume-id] args had no completion; added completeStorageRestoreCreateArgs which completes backup IDs at args[0] and block storage (volume) IDs at args[1]. Security family: no changes needed ? key and kmip resolve their KMS parent via --kms-id flag (already read in completeKeyID/completeKmipID), and all create/list commands in that family take no positional args. Tests: added coverage for all new delegation paths and too-many-args guards in completion_test.go. Co-Authored-By: Claude Sonnet 4.6 --- cmd/completion_test.go | 176 +++++++++++++++++++++++++++++++++ cmd/database.dbaas.database.go | 7 +- cmd/database.dbaas.grant.go | 13 ++- cmd/database.dbaas.user.go | 7 +- cmd/storage.backup.go | 1 + cmd/storage.restore.go | 14 +++ 6 files changed, 215 insertions(+), 3 deletions(-) diff --git a/cmd/completion_test.go b/cmd/completion_test.go index b2ea6c5..a2a32be 100644 --- a/cmd/completion_test.go +++ b/cmd/completion_test.go @@ -1047,3 +1047,179 @@ func TestCompleteVPCPeeringRouteID_TooManyArgs(t *testing.T) { t.Errorf("expected nil completions with too many args, got %v", comps) } } + +// ─── completeDBaaSDatabaseID parent-slot fixes ─────────────────────────────── + +func TestCompleteDBaaSDatabaseID_NoArgs_DelegatesToDBaaSID(t *testing.T) { + id, name := "dbaas-001", "my-dbaas" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Database/dbaas", jsonResponse(200, types.DBaaSListResponse{ + Values: []types.DBaaSResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeDBaaSDatabaseID(makeProjectCmd("proj-123"), []string{}, "") + if len(completions) == 0 { + t.Errorf("expected DBaaS IDs from delegation, got none") + } +} + +func TestCompleteDBaaSDatabaseID_NoArgs_NoProjectID(t *testing.T) { + cleanup := withTempHomeDir(t) + defer cleanup() + + comps, _ := completeDBaaSDatabaseID(&cobra.Command{}, []string{}, "") + if comps != nil { + t.Errorf("expected nil completions without project-id, got %v", comps) + } +} + +func TestCompleteDBaaSDatabaseID_TooManyArgs(t *testing.T) { + comps, _ := completeDBaaSDatabaseID(&cobra.Command{}, []string{"dbaas-001", "my-db"}, "") + if comps != nil { + t.Errorf("expected nil completions with too many args, got %v", comps) + } +} + +// ─── completeDBaaSUserID parent-slot fixes ──────────────────────────────────── + +func TestCompleteDBaaSUserID_NoArgs_DelegatesToDBaaSID(t *testing.T) { + id, name := "dbaas-001", "my-dbaas" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Database/dbaas", jsonResponse(200, types.DBaaSListResponse{ + Values: []types.DBaaSResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeDBaaSUserID(makeProjectCmd("proj-123"), []string{}, "") + if len(completions) == 0 { + t.Errorf("expected DBaaS IDs from delegation, got none") + } +} + +func TestCompleteDBaaSUserID_NoArgs_NoProjectID(t *testing.T) { + cleanup := withTempHomeDir(t) + defer cleanup() + + comps, _ := completeDBaaSUserID(&cobra.Command{}, []string{}, "") + if comps != nil { + t.Errorf("expected nil completions without project-id, got %v", comps) + } +} + +func TestCompleteDBaaSUserID_TooManyArgs(t *testing.T) { + comps, _ := completeDBaaSUserID(&cobra.Command{}, []string{"dbaas-001", "alice"}, "") + if comps != nil { + t.Errorf("expected nil completions with too many args, got %v", comps) + } +} + +// ─── completeGrantID parent-slot fixes ─────────────────────────────────────── + +func TestCompleteGrantID_NoArgs_DelegatesToDBaaSID(t *testing.T) { + id, name := "dbaas-001", "my-dbaas" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Database/dbaas", jsonResponse(200, types.DBaaSListResponse{ + Values: []types.DBaaSResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeGrantID(makeProjectCmd("proj-123"), []string{}, "") + if len(completions) == 0 { + t.Errorf("expected DBaaS IDs from delegation, got none") + } +} + +func TestCompleteGrantID_OneArg_DelegatesToDatabaseID(t *testing.T) { + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Database/dbaas/dbaas-001/databases", jsonResponse(200, types.DatabaseListResponse{ + Values: []types.DatabaseResponse{ + {Name: "my-db"}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeGrantID(makeProjectCmd("proj-123"), []string{"dbaas-001"}, "") + if len(completions) == 0 { + t.Errorf("expected database names from delegation, got none") + } +} + +func TestCompleteGrantID_TooManyArgs(t *testing.T) { + comps, _ := completeGrantID(&cobra.Command{}, []string{"dbaas-001", "my-db", "grant-id"}, "") + if comps != nil { + t.Errorf("expected nil completions with too many args, got %v", comps) + } +} + +// ─── completeStorageRestoreCreateArgs ──────────────────────────────────────── + +func TestCompleteStorageRestoreCreateArgs_NoArgs_DelegatesToBackupID(t *testing.T) { + id, name := "bkp-001", "my-backup" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Storage/backups", jsonResponse(200, types.StorageBackupListResponse{ + Values: []types.StorageBackupResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeStorageRestoreCreateArgs(makeProjectCmd("proj-123"), []string{}, "") + if len(completions) == 0 { + t.Errorf("expected backup IDs from delegation, got none") + } +} + +func TestCompleteStorageRestoreCreateArgs_OneArg_DelegatesToBlockStorageID(t *testing.T) { + id, name := "vol-001", "my-volume" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Storage/blockStorages", jsonResponse(200, types.BlockStorageListResponse{ + Values: []types.BlockStorageResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeStorageRestoreCreateArgs(makeProjectCmd("proj-123"), []string{"bkp-001"}, "") + if len(completions) == 0 { + t.Errorf("expected volume IDs from delegation, got none") + } +} + +func TestCompleteStorageRestoreCreateArgs_TooManyArgs(t *testing.T) { + comps, _ := completeStorageRestoreCreateArgs(&cobra.Command{}, []string{"bkp-001", "vol-001"}, "") + if comps != nil { + t.Errorf("expected nil completions with too many args, got %v", comps) + } +} + +// ─── storageBackupCmd create ValidArgsFunction ─────────────────────────────── + +func TestCompleteBackupCreateArg_DelegatesToBlockStorageID(t *testing.T) { + id, name := "vol-001", "my-volume" + srv := newArubaTestServer(t) + srv.OnGet("/projects/proj-123/providers/Aruba.Storage/blockStorages", jsonResponse(200, types.BlockStorageListResponse{ + Values: []types.BlockStorageResponse{ + {Metadata: types.ResourceMetadataResponse{ID: &id, Name: &name}}, + }, + })) + setClientForTesting(srv.Client()) + defer resetClientState() + + completions, _ := completeBlockStorageID(makeProjectCmd("proj-123"), nil, "") + if len(completions) == 0 { + t.Errorf("expected volume IDs, got none") + } +} diff --git a/cmd/database.dbaas.database.go b/cmd/database.dbaas.database.go index 7821047..b6facd1 100644 --- a/cmd/database.dbaas.database.go +++ b/cmd/database.dbaas.database.go @@ -34,13 +34,18 @@ func init() { dbaasDatabaseListCmd.Flags().Int("limit", 0, "Maximum number of results to return (0 = no limit)") dbaasDatabaseListCmd.Flags().Int("offset", 0, "Number of results to skip") + dbaasDatabaseCreateCmd.ValidArgsFunction = completeDBaaSDatabaseID + dbaasDatabaseListCmd.ValidArgsFunction = completeDBaaSDatabaseID dbaasDatabaseGetCmd.ValidArgsFunction = completeDBaaSDatabaseID dbaasDatabaseUpdateCmd.ValidArgsFunction = completeDBaaSDatabaseID dbaasDatabaseDeleteCmd.ValidArgsFunction = completeDBaaSDatabaseID } func completeDBaaSDatabaseID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) < 1 { + if len(args) == 0 { + return completeDBaaSID(cmd, args, toComplete) + } + if len(args) > 1 { return nil, cobra.ShellCompDirectiveNoFileComp } diff --git a/cmd/database.dbaas.grant.go b/cmd/database.dbaas.grant.go index 30a9edc..db89bdf 100644 --- a/cmd/database.dbaas.grant.go +++ b/cmd/database.dbaas.grant.go @@ -38,6 +38,11 @@ func init() { dbaasGrantDeleteCmd.Flags().String("project-id", "", "Project ID (uses context if not specified)") dbaasGrantDeleteCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt") dbaasGrantDeleteCmd.Flags().Bool("dry-run", false, "Validate resource exists without deleting") + + dbaasGrantCreateCmd.ValidArgsFunction = completeGrantID + dbaasGrantListCmd.ValidArgsFunction = completeGrantID + dbaasGrantGetCmd.ValidArgsFunction = completeGrantID + dbaasGrantDeleteCmd.ValidArgsFunction = completeGrantID } // grantRef returns a Ref for a specific grant inside a database inside a DBaaS instance. @@ -46,7 +51,13 @@ func grantRef(projectID, dbaasID, dbName, grantID string) aruba.Ref { } func completeGrantID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) < 2 { + if len(args) == 0 { + return completeDBaaSID(cmd, args, toComplete) + } + if len(args) == 1 { + return completeDBaaSDatabaseID(cmd, args, toComplete) + } + if len(args) > 2 { return nil, cobra.ShellCompDirectiveNoFileComp } projectID, err := GetProjectID(cmd) diff --git a/cmd/database.dbaas.user.go b/cmd/database.dbaas.user.go index 43360de..24b0e8b 100644 --- a/cmd/database.dbaas.user.go +++ b/cmd/database.dbaas.user.go @@ -47,13 +47,18 @@ func init() { dbaasUserListCmd.Flags().Int("limit", 0, "Maximum number of results to return (0 = no limit)") dbaasUserListCmd.Flags().Int("offset", 0, "Number of results to skip") + dbaasUserCreateCmd.ValidArgsFunction = completeDBaaSUserID + dbaasUserListCmd.ValidArgsFunction = completeDBaaSUserID dbaasUserGetCmd.ValidArgsFunction = completeDBaaSUserID dbaasUserUpdateCmd.ValidArgsFunction = completeDBaaSUserID dbaasUserDeleteCmd.ValidArgsFunction = completeDBaaSUserID } func completeDBaaSUserID(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if len(args) < 1 { + if len(args) == 0 { + return completeDBaaSID(cmd, args, toComplete) + } + if len(args) > 1 { return nil, cobra.ShellCompDirectiveNoFileComp } diff --git a/cmd/storage.backup.go b/cmd/storage.backup.go index 9aebae1..d6d6f25 100644 --- a/cmd/storage.backup.go +++ b/cmd/storage.backup.go @@ -48,6 +48,7 @@ func init() { storageBackupDeleteCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt") storageBackupDeleteCmd.Flags().Bool("dry-run", false, "Validate resource exists without deleting") + storageBackupCmd.ValidArgsFunction = completeBlockStorageID storageBackupGetCmd.ValidArgsFunction = completeBackupID storageBackupUpdateCmd.ValidArgsFunction = completeBackupID storageBackupDeleteCmd.ValidArgsFunction = completeBackupID diff --git a/cmd/storage.restore.go b/cmd/storage.restore.go index ca6eacd..027407e 100644 --- a/cmd/storage.restore.go +++ b/cmd/storage.restore.go @@ -46,6 +46,7 @@ func init() { storageRestoreDeleteCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt") storageRestoreDeleteCmd.Flags().Bool("dry-run", false, "Validate resource exists without deleting") + storageRestoreCmd.ValidArgsFunction = completeStorageRestoreCreateArgs storageRestoreGetCmd.ValidArgsFunction = completeRestoreID storageRestoreUpdateCmd.ValidArgsFunction = completeRestoreID storageRestoreDeleteCmd.ValidArgsFunction = completeRestoreID @@ -96,6 +97,19 @@ func completeRestoreID(cmd *cobra.Command, args []string, toComplete string) ([] return filterCompletions(completions, toComplete), cobra.ShellCompDirectiveNoFileComp } +// completeStorageRestoreCreateArgs completes the two positional args of +// "storage restore [backup-id] [volume-id]": backup IDs at args[0], block +// storage (volume) IDs at args[1]. +func completeStorageRestoreCreateArgs(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { + if len(args) == 0 { + return completeBackupID(cmd, args, toComplete) + } + if len(args) == 1 { + return completeBlockStorageID(cmd, args, toComplete) + } + return nil, cobra.ShellCompDirectiveNoFileComp +} + var storageRestoreCmd = &cobra.Command{ Use: "restore [backup-id] [volume-id]", Short: "Restore a block storage volume from a backup", From 8e64164e9d72c6860c390721e75237b1b66adbd9 Mon Sep 17 00:00:00 2001 From: Amedeo Palopoli Date: Fri, 19 Jun 2026 15:37:14 +0200 Subject: [PATCH 2/4] =?UTF-8?q?=EF=BB=BFdocs(completion):=20document=20hie?= =?UTF-8?q?rarchical=20auto-completion=20for=20all=20sub-resources?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Network resources (from #240): - subnet.md, securitygroup.md, vpcpeering.md: expand bare stubs into full examples showing parent-slot completion at args[0] and child-slot completion at args[1]. - securityrule.md, vpcpeeringroute.md: extend existing completion sections to show all three positional slots (were showing only the final slot). Database resources (from #241): - dbaas.database.md: add Shell Auto-completion section (dbaas-id ? database-name). - dbaas.user.md: add Shell Auto-completion section (dbaas-id ? username). - dbaas.grant.md: add Shell Auto-completion section (dbaas-id ? database-name ? grant-id). Storage resources (from #241): - backup.md: mark volume-id argument as supporting auto-completion. - restore.md: document create-command hierarchical completion (backup-id then volume-id), in addition to the existing get/list/delete section. getting-started.md: - Expand Storage section to cover backup create and restore create completion. - Add Database section showing sub-resource hierarchical completion examples. - Update closing note to mention create and list commands now also complete. Co-Authored-By: Claude Sonnet 4.6 --- docs/getting-started.md | 50 +++++++++++++++++-- .../docs/resources/database/dbaas.database.md | 16 ++++++ .../docs/resources/database/dbaas.grant.md | 19 +++++++ .../docs/resources/database/dbaas.user.md | 16 ++++++ .../docs/resources/network/securitygroup.md | 15 +++++- .../docs/resources/network/securityrule.md | 14 ++++-- docs/website/docs/resources/network/subnet.md | 14 +++++- .../docs/resources/network/vpcpeering.md | 14 +++++- .../docs/resources/network/vpcpeeringroute.md | 14 ++++-- docs/website/docs/resources/storage/backup.md | 2 +- .../website/docs/resources/storage/restore.md | 16 +++++- 11 files changed, 173 insertions(+), 17 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index 2bb5af9..9089bc6 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -322,14 +322,30 @@ The auto-completion system provides: # 696c9edce63c1af07d60d0c8 BackupSnapshot # ... - # Backups + # Backup create — completes volume ID + acloud storage backup + # Shows: + # 6965a6c3ffc0fd1ef8ba5612 MyVolume + # ... + + # Backup get/update/delete — completes backup ID acloud storage backup get # Shows: # 67649dac8c7bb1c5d7c80631 MyBackup # 67649dac8c7bb1c5d7c80632 DailyBackup # ... - # Restores (hierarchical: backup-id then restore-id) + # Restore create — hierarchical: backup-id then volume-id + acloud storage restore + # First shows backup IDs: + # 67649dac8c7bb1c5d7c80631 MyBackup + # ... + acloud storage restore 67649dac8c7bb1c5d7c80631 + # Then shows volume IDs: + # 6965a6c3ffc0fd1ef8ba5612 MyVolume + # ... + + # Restore get/update/delete — hierarchical: backup-id then restore-id acloud storage restore get # First shows backup IDs: # 67649dac8c7bb1c5d7c80631 MyBackup @@ -340,7 +356,35 @@ The auto-completion system provides: # ... ``` - Auto-completion works with `get`, `update`, and `delete` commands for all resources. + **Database Resources:** + ```bash + # DBaaS database commands — hierarchical: dbaas-id then database-name + acloud database dbaas database list + # Shows DBaaS instance IDs: + # 69455aa70d0972656501d45d my-dbaas + # ... + acloud database dbaas database get 69455aa70d0972656501d45d + # Shows database names in that instance: + # appdb + # reporting + # ... + + # DBaaS user commands — hierarchical: dbaas-id then username + acloud database dbaas user list + # Shows DBaaS instance IDs + acloud database dbaas user get 69455aa70d0972656501d45d + # Shows usernames in that instance + + # DBaaS grant commands — hierarchical: dbaas-id, database-name, grant-id + acloud database dbaas grant list + # Shows DBaaS instance IDs + acloud database dbaas grant list 69455aa70d0972656501d45d + # Shows database names + acloud database dbaas grant get 69455aa70d0972656501d45d appdb + # Shows grant IDs for that database + ``` + + Auto-completion works with `get`, `update`, `delete`, `list`, and `create` commands for all resources. ## Verifying Installation diff --git a/docs/website/docs/resources/database/dbaas.database.md b/docs/website/docs/resources/database/dbaas.database.md index 3a415d6..9ea5745 100644 --- a/docs/website/docs/resources/database/dbaas.database.md +++ b/docs/website/docs/resources/database/dbaas.database.md @@ -146,6 +146,22 @@ acloud database dbaas database delete [--yes] [flags] acloud database dbaas database delete 69455aa70d0972656501d45d "my-database" --yes ``` +## Shell Auto-completion + +Database commands support hierarchical auto-completion: the first TAB completes +DBaaS instance IDs, the second completes database names scoped to that instance. + +```bash +# First argument — shows available DBaaS instance IDs +acloud database dbaas database list +acloud database dbaas database get + +# Second argument — shows database names for the given DBaaS instance +acloud database dbaas database get +acloud database dbaas database update +acloud database dbaas database delete +``` + ## Related Resources - [DBaaS](dbaas.md) - Manage DBaaS instances diff --git a/docs/website/docs/resources/database/dbaas.grant.md b/docs/website/docs/resources/database/dbaas.grant.md index 124f9dd..4fc6106 100644 --- a/docs/website/docs/resources/database/dbaas.grant.md +++ b/docs/website/docs/resources/database/dbaas.grant.md @@ -145,6 +145,25 @@ acloud database dbaas grant create "appdb" --username "restapi" --rol acloud database dbaas grant list "appdb" ``` +## Shell Auto-completion + +Grant commands support hierarchical auto-completion across all three positional +arguments: + +```bash +# First argument — shows available DBaaS instance IDs +acloud database dbaas grant list +acloud database dbaas grant get + +# Second argument — shows database names for the given DBaaS instance +acloud database dbaas grant list +acloud database dbaas grant get + +# Third argument — shows grant IDs for the given DBaaS instance and database +acloud database dbaas grant get +acloud database dbaas grant delete +``` + ## Related Resources - [DBaaS](dbaas.md) - Manage DBaaS instances diff --git a/docs/website/docs/resources/database/dbaas.user.md b/docs/website/docs/resources/database/dbaas.user.md index e106691..58a8387 100644 --- a/docs/website/docs/resources/database/dbaas.user.md +++ b/docs/website/docs/resources/database/dbaas.user.md @@ -156,6 +156,22 @@ acloud database dbaas user delete 69455aa70d0972656501d45d "app-user" --yes - Never share passwords or commit them to version control - Consider using a password manager +## Shell Auto-completion + +User commands support hierarchical auto-completion: the first TAB completes +DBaaS instance IDs, the second completes usernames scoped to that instance. + +```bash +# First argument — shows available DBaaS instance IDs +acloud database dbaas user list +acloud database dbaas user get + +# Second argument — shows usernames for the given DBaaS instance +acloud database dbaas user get +acloud database dbaas user update +acloud database dbaas user delete +``` + ## Related Resources - [DBaaS](dbaas.md) - Manage DBaaS instances diff --git a/docs/website/docs/resources/network/securitygroup.md b/docs/website/docs/resources/network/securitygroup.md index 4d26fe1..0d3665f 100644 --- a/docs/website/docs/resources/network/securitygroup.md +++ b/docs/website/docs/resources/network/securitygroup.md @@ -126,7 +126,20 @@ Security Group 1234567890abcdef deleted successfully! ## Shell Auto-completion -The security group commands support auto-completion for VPC IDs and security group IDs. +Security group commands support hierarchical auto-completion: the first TAB +completes VPC IDs, the second completes security group IDs scoped to the +selected VPC. + +```bash +# First argument — shows available VPC IDs +acloud network securitygroup list +acloud network securitygroup get + +# Second argument — shows security group IDs for the given VPC +acloud network securitygroup get +acloud network securitygroup update +acloud network securitygroup delete +``` ## Best Practices - Use descriptive names and descriptions for security groups. diff --git a/docs/website/docs/resources/network/securityrule.md b/docs/website/docs/resources/network/securityrule.md index 894ec0d..9d30d47 100644 --- a/docs/website/docs/resources/network/securityrule.md +++ b/docs/website/docs/resources/network/securityrule.md @@ -250,13 +250,19 @@ ID STATUS ## Shell Auto-completion -The security rule commands support intelligent auto-completion for security rule IDs: +Security rule commands support hierarchical auto-completion across all three +positional arguments: ```bash -# Enable completion (bash) -source <(acloud completion bash) +# First argument — shows available VPC IDs +acloud network securityrule get +acloud network securityrule list -# Type command and press TAB to see available security rule IDs +# Second argument — shows security group IDs for the given VPC +acloud network securityrule get +acloud network securityrule list + +# Third argument — shows rule IDs for the given VPC and security group acloud network securityrule get acloud network securityrule update acloud network securityrule delete diff --git a/docs/website/docs/resources/network/subnet.md b/docs/website/docs/resources/network/subnet.md index c9cec83..22d5411 100644 --- a/docs/website/docs/resources/network/subnet.md +++ b/docs/website/docs/resources/network/subnet.md @@ -171,7 +171,19 @@ Subnet 1234567890abcdef deleted successfully! ## Shell Auto-completion -The subnet commands support auto-completion for VPC IDs and subnet IDs. +Subnet commands support hierarchical auto-completion: the first TAB completes +VPC IDs, the second completes subnet IDs scoped to the selected VPC. + +```bash +# First argument — shows available VPC IDs +acloud network subnet list +acloud network subnet get + +# Second argument — shows subnet IDs for the given VPC +acloud network subnet get +acloud network subnet update +acloud network subnet delete +``` ## Best Practices - Use descriptive names for subnets based on their purpose. diff --git a/docs/website/docs/resources/network/vpcpeering.md b/docs/website/docs/resources/network/vpcpeering.md index fcb6c66..e6c0037 100644 --- a/docs/website/docs/resources/network/vpcpeering.md +++ b/docs/website/docs/resources/network/vpcpeering.md @@ -134,7 +134,19 @@ VPC Peering 6949666e4d0cdc87949b7204 deleted successfully! ## Shell Auto-completion -The VPC Peering commands support auto-completion for VPC IDs and peering IDs. +VPC Peering commands support hierarchical auto-completion: the first TAB +completes VPC IDs, the second completes peering IDs scoped to the selected VPC. + +```bash +# First argument — shows available VPC IDs +acloud network vpcpeering list +acloud network vpcpeering get + +# Second argument — shows peering IDs for the given VPC +acloud network vpcpeering get +acloud network vpcpeering update +acloud network vpcpeering delete +``` ## Best Practices - Use descriptive names for peering connections. diff --git a/docs/website/docs/resources/network/vpcpeeringroute.md b/docs/website/docs/resources/network/vpcpeeringroute.md index fa0daf6..52639d6 100644 --- a/docs/website/docs/resources/network/vpcpeeringroute.md +++ b/docs/website/docs/resources/network/vpcpeeringroute.md @@ -217,13 +217,19 @@ ID STATUS ## Shell Auto-completion -The VPC Peering Route commands support intelligent auto-completion for route IDs: +VPC Peering Route commands support hierarchical auto-completion across all three +positional arguments: ```bash -# Enable completion (bash) -source <(acloud completion bash) +# First argument — shows available VPC IDs +acloud network vpcpeeringroute get +acloud network vpcpeeringroute list -# Type command and press TAB to see available route IDs +# Second argument — shows peering IDs for the given VPC +acloud network vpcpeeringroute get +acloud network vpcpeeringroute list + +# Third argument — shows route IDs for the given VPC and peering acloud network vpcpeeringroute get acloud network vpcpeeringroute update acloud network vpcpeeringroute delete diff --git a/docs/website/docs/resources/storage/backup.md b/docs/website/docs/resources/storage/backup.md index 792b5d8..20b0453 100644 --- a/docs/website/docs/resources/storage/backup.md +++ b/docs/website/docs/resources/storage/backup.md @@ -32,7 +32,7 @@ acloud storage backup --name [flags] ### Arguments -- `volume-id` - The ID of the block storage volume to backup +- `volume-id` - The ID of the block storage volume to backup (supports auto-completion) ### Required Flags diff --git a/docs/website/docs/resources/storage/restore.md b/docs/website/docs/resources/storage/restore.md index 4bddb1d..dd7b4ae 100644 --- a/docs/website/docs/resources/storage/restore.md +++ b/docs/website/docs/resources/storage/restore.md @@ -33,8 +33,20 @@ acloud storage restore --name [flags] ### Arguments -- `backup-id` - The ID of the backup to restore from -- `volume-id` - The ID of the target volume (will be overwritten) +- `backup-id` - The ID of the backup to restore from (supports auto-completion) +- `volume-id` - The ID of the target volume (supports auto-completion; will be overwritten) + +### Auto-completion + +The create command supports hierarchical auto-completion: + +```bash +# First argument — shows available backup IDs +acloud storage restore + +# Second argument — shows volume IDs once a backup is selected +acloud storage restore +``` ### Required Flags From 7e402adfa03b897137f6e6e648394167baf2aa59 Mon Sep 17 00:00:00 2001 From: Amedeo Palopoli Date: Fri, 19 Jun 2026 16:13:25 +0200 Subject: [PATCH 3/4] =?UTF-8?q?=EF=BB=BFdocs(completion):=20update=20Itali?= =?UTF-8?q?an=20docs=20with=20hierarchical=20auto-completion?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Mirror the English doc changes in the Italian translations under docs/website/i18n/it/docusaurus-plugin-content-docs/current/: Network resources: - subnet.md, securitygroup.md, vpcpeering.md: expand bare stubs into full examples showing parent-slot completion. - securityrule.md, vpcpeeringroute.md: extend to show all three positional slots (were showing only the final slot). Database resources: - dbaas.database.md: add "Auto-completamento Shell" section. - dbaas.user.md: add "Auto-completamento Shell" section. - dbaas.grant.md: add "Auto-completamento Shell" section (3-level chain). Storage resources: - backup.md: mark volume-id argument as supporting auto-completion. - restore.md: add create-command auto-completion block (backup-id then volume-id). Co-Authored-By: Claude Sonnet 4.6 --- .../resources/database/dbaas.database.md | 17 +++++++++++++++++ .../current/resources/database/dbaas.grant.md | 19 +++++++++++++++++++ .../current/resources/database/dbaas.user.md | 16 ++++++++++++++++ .../resources/network/securitygroup.md | 15 ++++++++++++++- .../current/resources/network/securityrule.md | 14 ++++++++++---- .../current/resources/network/subnet.md | 14 +++++++++++++- .../current/resources/network/vpcpeering.md | 15 ++++++++++++++- .../resources/network/vpcpeeringroute.md | 14 ++++++++++---- .../current/resources/storage/backup.md | 2 +- .../current/resources/storage/restore.md | 16 ++++++++++++++-- 10 files changed, 128 insertions(+), 14 deletions(-) diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.database.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.database.md index 80d3981..07d3031 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.database.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.database.md @@ -146,6 +146,23 @@ acloud database dbaas database delete [--yes] [flags] acloud database dbaas database delete 69455aa70d0972656501d45d "my-database" --yes ``` +## Auto-completamento Shell + +I comandi database supportano auto-completamento gerarchico: il primo TAB +completa gli ID istanza DBaaS, il secondo completa i nomi dei database limitati +a quell'istanza. + +```bash +# Primo argomento — mostra gli ID istanza DBaaS disponibili +acloud database dbaas database list +acloud database dbaas database get + +# Secondo argomento — mostra i nomi dei database per l'istanza DBaaS indicata +acloud database dbaas database get +acloud database dbaas database update +acloud database dbaas database delete +``` + ## Risorse Correlate - [DBaaS](dbaas.md) - Gestisci istanze DBaaS diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.grant.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.grant.md index 932f4a1..69ce36a 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.grant.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.grant.md @@ -145,6 +145,25 @@ acloud database dbaas grant create "appdb" --username "restapi" --rol acloud database dbaas grant list "appdb" ``` +## Auto-completamento Shell + +I comandi grant supportano auto-completamento gerarchico su tutti e tre gli +argomenti posizionali: + +```bash +# Primo argomento — mostra gli ID istanza DBaaS disponibili +acloud database dbaas grant list +acloud database dbaas grant get + +# Secondo argomento — mostra i nomi database per l'istanza DBaaS indicata +acloud database dbaas grant list +acloud database dbaas grant get + +# Terzo argomento — mostra gli ID grant per l'istanza e il database indicati +acloud database dbaas grant get +acloud database dbaas grant delete +``` + ## Risorse Correlate - [DBaaS](dbaas.md) - Gestisci istanze DBaaS diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.user.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.user.md index 2c2ff80..a648bbd 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.user.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/database/dbaas.user.md @@ -156,6 +156,22 @@ acloud database dbaas user delete 69455aa70d0972656501d45d "app-user" --yes - Non condividere mai password o committarle nel controllo versione - Considera l'uso di un password manager +## Auto-completamento Shell + +I comandi utente supportano auto-completamento gerarchico: il primo TAB completa +gli ID istanza DBaaS, il secondo completa i nomi utente limitati a quell'istanza. + +```bash +# Primo argomento — mostra gli ID istanza DBaaS disponibili +acloud database dbaas user list +acloud database dbaas user get + +# Secondo argomento — mostra i nomi utente per l'istanza DBaaS indicata +acloud database dbaas user get +acloud database dbaas user update +acloud database dbaas user delete +``` + ## Risorse Correlate - [DBaaS](dbaas.md) - Gestisci istanze DBaaS diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securitygroup.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securitygroup.md index e1fdbf1..b1cf050 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securitygroup.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securitygroup.md @@ -131,7 +131,20 @@ Security Group 1234567890abcdef deleted successfully! ## Auto-completamento Shell -I comandi security group supportano auto-completamento per ID VPC e ID security group. +I comandi security group supportano auto-completamento gerarchico: il primo TAB +completa gli ID VPC, il secondo completa gli ID security group limitati al VPC +selezionato. + +```bash +# Primo argomento — mostra gli ID VPC disponibili +acloud network securitygroup list +acloud network securitygroup get + +# Secondo argomento — mostra gli ID security group per il VPC indicato +acloud network securitygroup get +acloud network securitygroup update +acloud network securitygroup delete +``` ## Best Practices diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securityrule.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securityrule.md index 1f07dc0..e69260d 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securityrule.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/securityrule.md @@ -250,13 +250,19 @@ ID STATUS ## Auto-completamento Shell -I comandi security rule supportano auto-completamento intelligente per gli ID security rule: +I comandi security rule supportano auto-completamento gerarchico su tutti e tre +gli argomenti posizionali: ```bash -# Abilita completamento (bash) -source <(acloud completion bash) +# Primo argomento — mostra gli ID VPC disponibili +acloud network securityrule get +acloud network securityrule list -# Digita il comando e premi TAB per vedere gli ID security rule disponibili +# Secondo argomento — mostra gli ID security group per il VPC indicato +acloud network securityrule get +acloud network securityrule list + +# Terzo argomento — mostra gli ID rule per il VPC e security group indicati acloud network securityrule get acloud network securityrule update acloud network securityrule delete diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/subnet.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/subnet.md index 23f6f9f..721ffa4 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/subnet.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/subnet.md @@ -176,7 +176,19 @@ Subnet 1234567890abcdef deleted successfully! ## Auto-completamento Shell -I comandi subnet supportano auto-completamento per ID VPC e ID subnet. +I comandi subnet supportano auto-completamento gerarchico: il primo TAB completa +gli ID VPC, il secondo completa gli ID subnet limitati al VPC selezionato. + +```bash +# Primo argomento — mostra gli ID VPC disponibili +acloud network subnet list +acloud network subnet get + +# Secondo argomento — mostra gli ID subnet per il VPC indicato +acloud network subnet get +acloud network subnet update +acloud network subnet delete +``` ## Best Practices diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeering.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeering.md index 2ab1f9c..476fb16 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeering.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeering.md @@ -139,7 +139,20 @@ VPC Peering 6949666e4d0cdc87949b7204 deleted successfully! ## Auto-completamento Shell -I comandi VPC Peering supportano auto-completamento per ID VPC e ID peering. +I comandi VPC Peering supportano auto-completamento gerarchico: il primo TAB +completa gli ID VPC, il secondo completa gli ID peering limitati al VPC +selezionato. + +```bash +# Primo argomento — mostra gli ID VPC disponibili +acloud network vpcpeering list +acloud network vpcpeering get + +# Secondo argomento — mostra gli ID peering per il VPC indicato +acloud network vpcpeering get +acloud network vpcpeering update +acloud network vpcpeering delete +``` ## Best Practices diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeeringroute.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeeringroute.md index 820994b..83042c0 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeeringroute.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/network/vpcpeeringroute.md @@ -217,13 +217,19 @@ ID STATUS ## Auto-completamento Shell -I comandi VPC Peering Route supportano auto-completamento intelligente per gli ID route: +I comandi VPC Peering Route supportano auto-completamento gerarchico su tutti e +tre gli argomenti posizionali: ```bash -# Abilita completamento (bash) -source <(acloud completion bash) +# Primo argomento — mostra gli ID VPC disponibili +acloud network vpcpeeringroute get +acloud network vpcpeeringroute list -# Digita il comando e premi TAB per vedere gli ID route disponibili +# Secondo argomento — mostra gli ID peering per il VPC indicato +acloud network vpcpeeringroute get +acloud network vpcpeeringroute list + +# Terzo argomento — mostra gli ID route per il VPC e peering indicati acloud network vpcpeeringroute get acloud network vpcpeeringroute update acloud network vpcpeeringroute delete diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/backup.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/backup.md index 7973e39..57720d5 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/backup.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/backup.md @@ -32,7 +32,7 @@ acloud storage backup --name [flags] ### Argomenti -- `volume-id` - L'ID del volume di block storage da cui fare il backup +- `volume-id` - L'ID del volume di block storage da cui fare il backup (supporta auto-completamento) ### Flag Richiesti diff --git a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/restore.md b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/restore.md index cce622a..680ba4c 100644 --- a/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/restore.md +++ b/docs/website/i18n/it/docusaurus-plugin-content-docs/current/resources/storage/restore.md @@ -33,8 +33,20 @@ acloud storage restore --name [flags] ### Argomenti -- `backup-id` - L'ID del backup da cui ripristinare -- `volume-id` - L'ID del volume target (sarà sovrascritto) +- `backup-id` - L'ID del backup da cui ripristinare (supporta auto-completamento) +- `volume-id` - L'ID del volume target (supporta auto-completamento; sarà sovrascritto) + +### Auto-completamento + +Il comando create supporta auto-completamento gerarchico: + +```bash +# Primo argomento — mostra gli ID backup disponibili +acloud storage restore + +# Secondo argomento — mostra gli ID volume una volta selezionato un backup +acloud storage restore +``` ### Flag Richiesti From 9cecd3c5127ac24da7dc3fdd915435c66f8efbaa Mon Sep 17 00:00:00 2001 From: Amedeo Palopoli Date: Fri, 19 Jun 2026 16:24:08 +0200 Subject: [PATCH 4/4] =?UTF-8?q?=EF=BB=BFdocs:=20add=20v0.5.2=20changelog?= =?UTF-8?q?=20entry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Covers all changes since v0.5.1: - feat: context auto-selection (#234) - feat: clear-contexts prompt on profile switch (#236) - fix: shell completion parent-ID slots for network sub-resources (#239/#240) - fix: shell completion parent-ID slots for database/storage sub-resources (#241) - fix: zone value in docs examples (#238) - docs: English and Italian completion section updates Co-Authored-By: Claude Sonnet 4.6 --- CHANGELOG.md | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 45336b4..8e2769c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,60 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.5.2] - 2026-06-19 + +### Added + +- **Context auto-selection** — when exactly one context is configured and no + `CurrentContext` is set, `GetCurrentProjectID()` now automatically selects it. + Running `acloud context set` no longer requires a follow-up `acloud context use` + in the single-context case (closes #234). +- **Clear-contexts prompt on profile switch** — switching to a different credential + profile with `--profile` (or `ACLOUD_PROFILE`) now detects that existing contexts + belong to the previous profile's projects and offers to clear them interactively. + Prevents stale contexts from causing "project not found" errors after a profile + change (closes #236). + +### Fixed + +- **Shell completion — network sub-resources** — pressing TAB at any positional + argument slot in nested network commands now suggests the correct parent resource + IDs instead of falling back to filesystem completion. Previously, only the final + slot (the resource's own ID) was completed; all earlier slots returned nothing. + Fixed resources and their full TAB sequences: + - `subnet list/get/create ` → VPC IDs; `subnet get ` → subnet IDs + - `securitygroup list/get/create ` → VPC IDs; `securitygroup get ` → SG IDs + - `vpcpeering list/get/create ` → VPC IDs; `vpcpeering get ` → peering IDs + - `securityrule get/list ` → VPC IDs; `… ` → SG IDs; `… ` → rule IDs + - `vpcpeeringroute get/list ` → VPC IDs; slot 2 → peering IDs; slot 3 → route IDs + + Completion is now also registered on `list` and `create` commands that + previously had no `ValidArgsFunction` at all (closes #239, PR #240). + +- **Shell completion — database and storage sub-resources** — same class of fix + extended to the database and storage families (PR #241): + - `dbaas database list/create ` → DBaaS IDs; slot 2 → database names + - `dbaas user list/create ` → DBaaS IDs; slot 2 → usernames + - `dbaas grant list/create ` → DBaaS IDs; slot 2 → database names; slot 3 → grant IDs + (`create`, `list`, `get`, `delete` had no `ValidArgsFunction` at all) + - `storage backup ` (create command) → volume IDs + - `storage restore ` (create command) → backup IDs; slot 2 → volume IDs + +- **Docs**: corrected zone value from `itbg1-a` to `ITBG-1` in cloud server + create examples (closes #238). + +### Documentation + +- Shell auto-completion sections updated in English and Italian across all + resource pages affected by the completion fixes: `subnet`, `securitygroup`, + `vpcpeering`, `securityrule`, `vpcpeeringroute`, `dbaas.database`, `dbaas.user`, + `dbaas.grant`, `storage/backup`, `storage/restore`. Each section now shows the + full hierarchical TAB sequence for every positional argument slot rather than + only the final one. +- `getting-started.md` auto-completion examples extended to cover `storage backup` + create (volume ID), `storage restore` create (backup ID then volume ID), and + database sub-resource hierarchical completion (DBaaS → database → user/grant). + ## [0.5.1] - 2026-06-19 ### Fixed @@ -262,7 +316,8 @@ is unchanged. - **E2e**: project `DELETE` failure now propagates correctly in the management suite (closes #128). -[Unreleased]: https://github.com/Arubacloud/acloud-cli/compare/v0.5.1...HEAD +[Unreleased]: https://github.com/Arubacloud/acloud-cli/compare/v0.5.2...HEAD +[0.5.2]: https://github.com/Arubacloud/acloud-cli/compare/v0.5.1...v0.5.2 [0.5.1]: https://github.com/Arubacloud/acloud-cli/compare/v0.5.0...v0.5.1 [0.5.0]: https://github.com/Arubacloud/acloud-cli/compare/v0.4.0...v0.5.0 [0.4.0]: https://github.com/Arubacloud/acloud-cli/compare/v0.3.0...v0.4.0