Skip to content

Add map argument autocomplete - #229

Open
dheeraj12347 wants to merge 1 commit into
apache:mainfrom
dheeraj12347:feature/map-autocomplete
Open

dheeraj12347 wants to merge 1 commit into
apache:mainfrom
dheeraj12347:feature/map-autocomplete

Conversation

@dheeraj12347

Copy link
Copy Markdown
Contributor

Summary

Add autocomplete support for map API arguments in CloudMonkey.

Changes

  • Add support for map argument autocomplete.
  • Extract indexed map fields from API argument descriptions.
  • Support generic key/value map descriptions.
  • Suggest indexed fields such as:
    • tags[0].key=
    • tags[0].value=
  • Avoid assuming that every map argument follows the key/value structure.
  • Add regression tests covering:
    • Indexed map fields
    • Multiple map fields
    • Multiple indexes
    • Generic key/value maps
    • Non-key/value map arguments
    • Autocomplete option generation

Testing

  • gofmt -w cli/completer_test.go
  • go test ./...
  • git diff --check

All tests are passing.

@dheeraj12347

Copy link
Copy Markdown
Contributor Author

Hi @Pearl1594 and @DaanHoogland , I’ve raised the map argument autocomplete work as a separate PR: #229.

It adds autocomplete support for map API arguments, including indexed fields like tags[0].key= and tags[0].value=, while avoiding assumptions about maps that don’t follow the key/value structure. I’ve also added regression tests covering the different cases.

go test ./... and git diff --check are passing.

Whenever you’re available, could you please have a look and let me know if the approach looks good or if anything should be changed?

PR: #229

@DaanHoogland
DaanHoogland requested review from Pearl1594 and a balanced review from Copilot October 5, 2026 08:08
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown

✅ Build complete for PR #229.

📦 Binary artifacts are available in the workflow run (expires on October 15, 2026).

Note: Download artifacts by clicking on the workflow run link above, then scroll to the "Artifacts" section.
Artifacts from PR builds are for testing only and may contain unreviewed, malicious code.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Argument routing prevents indexed map suggestions from appearing with real cached argument names.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds description-based autocomplete for CloudMonkey map arguments without assuming every map uses key/value fields.

Changes:

  • Extracts indexed fields from argument descriptions.
  • Adds generic key/value suggestions.
  • Adds regression tests for field extraction and suggestion generation.
File Description
cli/​completer.go Adds map-field extraction and completion handling.
cli/​completer_test.go Tests indexed, generic, and non-key/value maps.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cli/completer.go
Comment on lines +460 to +461
if arg.Type == "map" {
suggestions := mapFieldSuggestions(arg)
@Damans227

Copy link
Copy Markdown

the new map suggestions never show up when you press tab. typing tags gives only "=", and tags= or tags[0].k give nothing, because the new part only runs after the full tags= is typed and none of its suggestions start with tags=. copilot's comment above is right. can we add a test that goes through the normal tab completion with tags= so this gets caught?

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.

3 participants