Skip to content

Use ValidArgsFunction to autocomplete dynamic arguments like asset IDs #105

@mmanciop

Description

@mmanciop

Problem

Commands that take asset IDs as positional arguments (e.g., dashboards get <id>, dashboards delete <id>, teams get <id>) currently offer no shell completion for those arguments.
Users must look up IDs manually before running the command.

Desired behavior

Cobra's ValidArgsFunction allows commands to provide dynamic completions at runtime.
Commands that accept an asset ID (or similar dynamic value) as a positional argument should use ValidArgsFunction to query the Dash0 API and suggest matching IDs.

This would enable tab-completion workflows like:

dash0 dashboards get <TAB>
a1b2c3d4-...  Production Overview
d4e5f6a7-...  Staging Overview

Scope

Asset commands that take an ID argument:

  • dashboards get, dashboards update, dashboards delete
  • check-rules get, check-rules update, check-rules delete
  • views get, views update, views delete
  • synthetic-checks get, synthetic-checks update, synthetic-checks delete
  • teams get, teams update, teams delete
  • teams list-members, teams add-members, teams remove-members
  • members remove
  • traces get (trace ID)
  • config profiles select, config profiles update, config profiles delete (profile names)

Acceptance criteria

  • Commands that accept a dynamic positional argument use ValidArgsFunction to offer completions.
  • Completions that require API calls gracefully degrade (return no suggestions) when credentials are unavailable or the API call fails.
  • Profile commands complete from the local profile list (no API call needed).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions