Skip to content

fix: add create-command auto-completion for sub-resource parent IDs#251

Merged
aru-amedeo merged 3 commits into
mainfrom
fix/create-cmd-completion
Jun 22, 2026
Merged

fix: add create-command auto-completion for sub-resource parent IDs#251
aru-amedeo merged 3 commits into
mainfrom
fix/create-cmd-completion

Conversation

@aru-amedeo

Copy link
Copy Markdown
Member

Summary

All create commands that take parent resource IDs as positional arguments
now correctly complete only those parent IDs, then stop — they no longer
offer the resource's own IDs on subsequent TAB presses.

Additionally, vpnroute get/update/delete now complete the first argument
(VPN tunnel ID) on TAB, which was previously broken (returning nothing).

Changes

cmd/ (code)

  • network.subnet.go: add completeSubnetCreate (vpc-id only); add missing Args: cobra.ExactArgs(1) to subnetCreateCmd
  • network.securitygroup.go: add completeSecurityGroupCreate (vpc-id only)
  • network.securityrule.go: add completeSecurityRuleCreate (vpc-id → sg-id, then stop)
  • network.vpcpeering.go: add completeVPCPeeringCreate (vpc-id only)
  • network.vpcpeeringroute.go: add completeVPCPeeringRouteCreate (vpc-id → peering-id, then stop)
  • network.vpnroute.go: fix completeVPNRouteID to complete tunnel-id on first TAB; add completeVPNRouteCreate; wire create/list commands
  • database.dbaas.database.go: add completeDBaasDatabaseCreate (dbaas-id only)
  • database.dbaas.user.go: add completeDBaaSUserCreate (dbaas-id only)

docs/

  • Updated Shell Auto-completion sections for all affected resources to
    include the create (and list) commands, reflecting the new behavior.

Test plan

  • acloud network subnet create <TAB> → shows VPC IDs
  • acloud network subnet create <vpc-id> <TAB> → no suggestions (correct)
  • acloud network securitygroup create <TAB> → shows VPC IDs
  • acloud network securitygroup create <vpc-id> <TAB> → no suggestions
  • acloud network securityrule create <TAB> → shows VPC IDs
  • acloud network securityrule create <vpc-id> <TAB> → shows SG IDs
  • acloud network securityrule create <vpc-id> <sg-id> <TAB> → no suggestions
  • acloud network vpnroute get <TAB> → shows VPN tunnel IDs (was broken)
  • acloud network vpnroute create <TAB> → shows VPN tunnel IDs (was missing)
  • acloud network vpnroute list <TAB> → shows VPN tunnel IDs (was missing)
  • acloud database dbaas database create <TAB> → shows DBaaS IDs
  • acloud database dbaas database create <dbaas-id> <TAB> → no suggestions
  • acloud database dbaas user create <TAB> → shows DBaaS IDs
  • go test ./cmd/... passes

Closes #250

🤖 Generated with Claude Code

All `create` commands that take parent resource IDs as positional arguments
now correctly complete only those parent IDs and stop — they no longer
incorrectly offer the resource's own IDs on subsequent TAB presses.

Changes per resource:

Network:
- subnet create: dedicated completeSubnetCreate; adds missing Args: ExactArgs(1)
- securitygroup create: dedicated completeSecurityGroupCreate (vpc-id only)
- securityrule create: dedicated completeSecurityRuleCreate (vpc-id → sg-id)
- vpcpeering create: dedicated completeVPCPeeringCreate (vpc-id only)
- vpcpeeringroute create: dedicated completeVPCPeeringRouteCreate (vpc-id → peering-id)
- vpnroute create/list: new completeVPNRouteCreate + completeVPNTunnelID for list;
  fix completeVPNRouteID to complete tunnel-id on first TAB (was returning nil)

Database:
- dbaas database create: dedicated completeDBaasDatabaseCreate (dbaas-id only)
- dbaas user create: dedicated completeDBaaSUserCreate (dbaas-id only)

Docs: updated Shell Auto-completion sections for all affected resources to
include the create (and list) commands.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.27%. Comparing base (c7103a0) to head (ca2aac3).
⚠️ Report is 20 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #251      +/-   ##
==========================================
+ Coverage   78.20%   78.27%   +0.06%     
==========================================
  Files          53       53              
  Lines       12593    12633      +40     
==========================================
+ Hits         9848     9888      +40     
  Misses       1575     1575              
  Partials     1170     1170              
Flag Coverage Δ
unittests 78.27% <100.00%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

amedeopalopoli and others added 2 commits June 22, 2026 10:02
Add tests for all new completion functions introduced in the previous
commit, covering every code path:

- completeSubnetCreate (delegates to VPC on arg 0, nil after)
- completeSecurityGroupCreate (delegates to VPC on arg 0, nil after)
- completeSecurityRuleCreate (VPC → SG → nil)
- completeVPCPeeringCreate (delegates to VPC on arg 0, nil after)
- completeVPCPeeringRouteCreate (VPC → peering → nil)
- completeVPNRouteCreate (delegates to VPN tunnel on arg 0, nil after)
- completeDBaasDatabaseCreate (delegates to DBaaS on arg 0, nil after)
- completeDBaaSUserCreate (delegates to DBaaS on arg 0, nil after)
- completeVPNRouteID: new arg-0 delegation to VPN tunnel + TooManyArgs guard

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mmands

Mirror the English completion-section changes across all Italian i18n files:
subnet, securitygroup, securityrule, vpcpeering, vpcpeeringroute, vpnroute,
dbaas.database, dbaas.user — adding create (and list for vpnroute) to the
first-argument TAB examples and explaining that create stops after the
parent resource IDs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@aru-amedeo aru-amedeo merged commit f256cf4 into main Jun 22, 2026
aru-amedeo pushed a commit that referenced this pull request Jun 22, 2026
First stable GA release. Covers the two fixes landed since v0.5.3:
- #249/#251: securitygroup/securityrule doc examples corrected
- #250/#251: create-command completion for nested resources, vpnroute
  completion gap, and subnet ExactArgs constraint

Also adds the v0.5.3 comparison link which was previously missing from
the footer, and updates [Unreleased] to point to v1.0.0.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

fix: create commands for sub-resources missing parent-ID auto-completion

2 participants