Skip to content

Add map argument autocomplete - #229

Open
dheeraj12347 wants to merge 2 commits into
apache:mainfrom
dheeraj12347:feature/map-autocomplete
Open

dheeraj12347 wants to merge 2 commits 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 Outdated
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?

@dheeraj12347

Copy link
Copy Markdown
Contributor Author

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?

Thanks for the feedback! I've pushed a follow-up commit, c79972f, that moves map-field matching before the argument-prefix check and adds a regression test through the normal autoCompleter.Do path using tags=. The focused test and full go test ./... suite pass locally. Could you please review the updated implementation when you get a chance?

@Damans227

Copy link
Copy Markdown

I've pushed a follow-up commit, c79972f, that moves map-field matching before the argument-prefix check

@dheeraj12347 tags and tags[0].k work now, but tags= still breaks in the real shell. pressing tab there gives tags=[0]. because the shell adds the text after the = instead of replacing it. can the test check the full line after tab, not just the suggestions?

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