Skip to content

Autocomplete consistency for app/job/secret/valkey/opensearch commands#668

Merged
rbjornstad merged 28 commits intomainfrom
feat/autocomplete-consistency
Mar 16, 2026
Merged

Autocomplete consistency for app/job/secret/valkey/opensearch commands#668
rbjornstad merged 28 commits intomainfrom
feat/autocomplete-consistency

Conversation

@rbjornstad
Copy link
Contributor

@rbjornstad rbjornstad commented Mar 13, 2026

Summary

This PR improves autocomplete consistency and environment handling across app, job, secret, valkey, and opensearch commands.

Main goals:

  • predictable resource-name autocomplete behavior
  • clear guidance when required context is missing (team/environment)
  • robust behavior when completion context has incomplete parsed flags
  • stricter validation for single-resource secret commands

Changes

Secrets

  • Enforced single-environment validation for:
    • secrets get
    • secrets delete
    • secrets set
    • secrets unset
  • Added environment parsing from CLI args in completion context.
  • Updated autocomplete behavior:
    • require environment for single-resource commands
    • support union filtering for secrets activity when multiple -e are provided
    • avoid cross-environment suggestions when environment is explicitly set

App / Job

  • Improved app activity and job activity autocomplete to better respect environment in completion context.
  • Added missing team guidance for job list.
  • Simplified app list autocomplete UX:
    • keep team guidance
    • do not require environment (command is valid without it)

Valkey

  • Harmonized name autocomplete for:
    • valkey get
    • valkey delete
    • valkey update
  • Requires environment before suggesting names and filters by selected environment.

OpenSearch

  • Applied same pattern for:
    • opensearch get
    • opensearch delete
    • opensearch update
  • Added robust environment fallback from CLI args for completion contexts.

Why

Autocomplete behavior was inconsistent across command groups and could:

  • suggest resources from wrong environments
  • ignore provided -e/--environment in completion context
  • show unclear or missing guidance messages

This PR makes behavior consistent and safer for environment-scoped commands.

Validation

  • go test ./internal/secret/command ./internal/app/command ./internal/job/command ./internal/opensearch/command
  • go build ./...
  • go build -o nais . && source <(./nais completion zsh)

Manual smoke checks:

  • app list, app activity
  • job list, job activity
  • secrets get, secrets activity
  • valkey get
  • opensearch get

Notes

  • valkey and opensearch are now top-level commands (moved out of alpha).

@rbjornstad rbjornstad requested a review from Copilot March 13, 2026 15:58
@github-actions
Copy link
Contributor

github-actions bot commented Mar 13, 2026

📝 Changelog preview

Below is a preview of the Changelog that will be added to the next release. Only commit messages that follow the Conventional Commits specification will be included in the Changelog.

v5.14.0 - 2026-03-16

Full Changelog: v5.13.1...v5.14.0

🚀 Features

  • (secret) Tighten environment-aware autocomplete and validation (0ef1b32)
  • (app) Improve list and activity autocomplete UX (f7516b7)
  • (valkey) Require environment for name autocomplete (ac23e7e)
  • (opensearch) Require environment for name autocomplete (888cce8)
  • (secret) Update autocomplete behavior for secret names (b8a6bbe)
  • (cli) Move valkey and opensearch out of alpha (381a0d3)

🐛 Bug Fixes

  • (secret) Validate provided environment in resolver (80fb5ab)
  • (secret) Clarify env flag validation error (5ad307b)
  • (secret) Handle reason prompt errors explicitly (7090df3)
  • (app) Allow activity autocomplete without environment filter (0466542)
  • (job) Allow activity autocomplete without environment filter (4840341)
  • (opensearch) Reject repeated environment flags in autocomplete (fe136d1)
  • (secret) Allow get autocomplete without environment (07af7e9)
  • (valkey) Reject repeated environment flags in autocomplete (eb870fa)
  • (cliflags) Stop parsing flags after -- marker (d69da16)
  • (secret) Reject repeated environment flags in autocomplete (2a98bab)
  • (commands) Address follow-up review feedback (173473c)
  • (valkey,opensearch) Enforce single environment flag at runtime (dcea17e)
  • (activity) Use []string env fallback in autocomplete (bd85df9)
  • (secret) Validate provided environment in get (43c4d4d)

⚙️ Miscellaneous Changes

  • (flags) Share cli flag parsing helpers (beb81c0)
  • (environment) Simplify environment existence check using slices.Contains (9346dd6)
  • (secret) Cover environment resolver branches (c0fc184)
  • (cliflags) Add coverage for flag parsing helpers (7a7c7f8)
  • (tests) Remove unnecessary variable declaration in flag tests (7d0751b)
  • (app,job) Avoid unused autocomplete ctx params (8df1e2a)

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors and standardizes CLI auto-completion for several resource commands (Valkey, OpenSearch, Secrets, Apps, Jobs), and adds more explicit handling of environment flag usage—particularly for secrets where the environment can be inferred at runtime.

Changes:

  • Extracted shared auto-completion helpers for Valkey and OpenSearch instance names (dedupe + sort + optional environment filtering).
  • Reworked secret name auto-completion to support environment filtering, and added secret environment resolution logic for secrets get.
  • Added CLI-arg parsing helpers to infer --environment values for auto-completion in some commands, plus added “missing team” feedback in list commands.

Reviewed changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Uses shared Valkey name auto-completion helper.
internal/valkey/command/get.go Uses shared Valkey name auto-completion helper.
internal/valkey/command/delete.go Uses shared Valkey name auto-completion helper.
internal/valkey/command/command.go Adds autoCompleteValkeyNames (dedupe/sort/filter).
internal/opensearch/command/update.go Uses shared OpenSearch name auto-completion helper.
internal/opensearch/command/get.go Uses shared OpenSearch name auto-completion helper.
internal/opensearch/command/delete.go Uses shared OpenSearch name auto-completion helper.
internal/opensearch/command/command.go Adds autoCompleteOpenSearchNames + CLI arg environment parsing helper.
internal/secret/command/command.go Refactors secret name auto-completion with environment filtering and sorting.
internal/secret/command/environment.go Adds secret environment resolution + environment flag counting/parsing helpers.
internal/secret/command/get.go Updates validation flow and runtime environment resolution for secrets get; refactors run logic into helper.
internal/secret/command/set.go Adds single-environment-flag usage validation; updates secret-name auto-completion call.
internal/secret/command/unset.go Adds single-environment-flag usage validation; updates secret-name auto-completion call.
internal/secret/command/delete.go Adds single-environment-flag usage validation; updates secret-name auto-completion call.
internal/secret/command/activity.go Uses parsed CLI environments for secret-name auto-completion when flags aren’t populated.
internal/app/command/list.go Adds AutoCompleteFunc to surface missing-team guidance.
internal/app/command/activity.go Adds CLI parsing fallback to require environment(s) for activity name completion.
internal/job/command/list.go Adds AutoCompleteFunc to surface missing-team guidance.
internal/job/command/activity.go Adds CLI parsing fallback to require environment(s) for activity name completion.
Comments suppressed due to low confidence (1)

internal/secret/command/get.go:45

  • secrets get no longer validates the value of --environment. If the user provides an invalid environment string, resolveSecretEnvironment returns it as-is and the command proceeds to call the API, which can lead to confusing downstream errors. Consider reintroducing validation.CheckEnvironment(string(f.Environment)) when the flag is set, or validating provided inside resolveSecretEnvironment before returning it.
		ValidateFunc: func(_ context.Context, args *naistrix.Arguments) error {
			if err := validateSingleEnvironmentFlagUsage(); err != nil {
				return err
			}
			if err := validateArgs(args); err != nil {
				return err
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors several CLI commands to centralize and improve shell auto-completion behavior (especially around filtering by environment), and enhances secret handling by resolving the secret environment when not explicitly provided.

Changes:

  • Centralize name auto-completion for Valkey and OpenSearch instances (dedupe + sort + optional environment filtering).
  • Improve secret commands by adding environment resolution logic and stricter detection of multiple --environment/-e flag usages.
  • Introduce a small internal/cliflags helper for extracting/counting flag values directly from raw CLI args (used primarily in completion paths).

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Switch Valkey name completion to shared helper.
internal/valkey/command/get.go Switch Valkey name completion to shared helper.
internal/valkey/command/delete.go Switch Valkey name completion to shared helper.
internal/valkey/command/command.go Add autoCompleteValkeyNames helper (dedupe/sort/filter by environment).
internal/secret/command/unset.go Enforce single environment flag usage; update completion call signature.
internal/secret/command/set.go Enforce single environment flag usage; update completion call signature.
internal/secret/command/get.go Resolve environment dynamically; refactor run logic into runGetCommand.
internal/secret/command/environment.go New helpers for resolving secret environment and inspecting raw --environment/-e usage.
internal/secret/command/delete.go Enforce single environment flag usage; update completion call signature.
internal/secret/command/command.go Refactor/extend secret name completion with environment filtering + sorting.
internal/secret/command/activity.go Allow completion across multiple environments (including from raw CLI args).
internal/opensearch/command/update.go Switch OpenSearch name completion to shared helper.
internal/opensearch/command/get.go Switch OpenSearch name completion to shared helper.
internal/opensearch/command/delete.go Switch OpenSearch name completion to shared helper.
internal/opensearch/command/command.go Add autoCompleteOpenSearchNames helper + raw env parsing fallback.
internal/job/command/list.go Add completion-time hint when team is missing.
internal/job/command/activity.go Completion now derives envs from raw args when needed.
internal/cliflags/flags.go New utilities for parsing unique flag values / counting occurrences from args.
internal/app/command/list.go Add completion-time hint when team is missing.
internal/app/command/activity.go Completion now derives envs from raw args when needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CLI auto-completion and environment handling across multiple commands by centralizing “name” completion logic, adding CLI flag parsing helpers, and making secrets get capable of resolving the environment when omitted.

Changes:

  • Refactors Valkey/OpenSearch name auto-completion into shared helper functions with environment filtering and sorted/deduped results.
  • Enhances secrets commands with multi-environment handling utilities (including environment resolution for secrets get) and stronger --environment/-e usage validation.
  • Introduces internal/cliflags helpers (with tests) to parse repeated flag values from raw CLI args, used by activity auto-completion.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Switches instance-name autocomplete to new Valkey helper.
internal/valkey/command/get.go Switches instance-name autocomplete to new Valkey helper.
internal/valkey/command/delete.go Switches instance-name autocomplete to new Valkey helper.
internal/valkey/command/command.go Adds autoCompleteValkeyNames helper (dedupe + env filter + sort).
internal/secret/command/unset.go Adds single-environment flag usage validation; updates autocomplete call signature.
internal/secret/command/set.go Adds single-environment flag usage validation; updates autocomplete call signature.
internal/secret/command/get.go Adds environment auto-resolution and refactors run logic into runGetCommand; updates autocomplete call signature.
internal/secret/command/environment.go Adds environment resolution/selection logic and CLI env-flag occurrence utilities.
internal/secret/command/environment_test.go Adds unit tests for selectSecretEnvironment.
internal/secret/command/delete.go Adds single-environment flag usage validation; updates autocomplete call signature.
internal/secret/command/command.go Refactors secret-name autocomplete with env filtering, dedupe, and sorting.
internal/secret/command/activity.go Uses CLI env-flag parsing fallback for autocomplete environment filtering.
internal/opensearch/command/update.go Switches instance-name autocomplete to new OpenSearch helper.
internal/opensearch/command/get.go Switches instance-name autocomplete to new OpenSearch helper.
internal/opensearch/command/delete.go Switches instance-name autocomplete to new OpenSearch helper.
internal/opensearch/command/command.go Adds autoCompleteOpenSearchNames helper and CLI env parsing helper.
internal/job/command/list.go Adds an autocomplete hook that prompts for missing team (no suggestions returned).
internal/job/command/activity.go Uses CLI env-flag parsing fallback to pass environments into GetJobNames.
internal/cliflags/flags.go Adds UniqueFlagValues / CountFlagOccurrences for raw CLI arg inspection.
internal/cliflags/flags_test.go Adds unit tests for UniqueFlagValues and CountFlagOccurrences.
internal/app/command/list.go Adds an autocomplete hook that prompts for missing team (no suggestions returned).
internal/app/command/activity.go Uses CLI env-flag parsing fallback to pass environments into GetApplicationNames.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors CLI command registration and auto-completion to better handle environment/team context, and promotes some commands from the alpha command group to the main CLI.

Changes:

  • Promote valkey and opensearch commands to top-level (remove from alpha) and refactor their flags to use flags.GlobalFlags.
  • Centralize instance-name autocompletion for Valkey/OpenSearch with environment filtering and sorted/deduped results.
  • Improve secret environment handling (auto-resolve environment for secrets get, enforce single --environment/-e usage for single-env secret commands), and add a small cliflags utility for reading repeated -e/--environment values from os.Args.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/valkey/command/command.go Adds shared Valkey name auto-complete helper and switches command to GlobalFlags.
internal/valkey/command/flag/flag.go Replaces embedded alpha flags with *flags.GlobalFlags.
internal/valkey/command/get.go Uses centralized Valkey name auto-completion.
internal/valkey/command/delete.go Uses centralized Valkey name auto-completion.
internal/valkey/command/update.go Uses centralized Valkey name auto-completion.
internal/opensearch/command/command.go Adds shared OpenSearch name auto-complete helper (incl. CLI env flag inspection) and switches command to GlobalFlags.
internal/opensearch/command/flag/flag.go Replaces embedded alpha flags with *flags.GlobalFlags.
internal/opensearch/command/get.go Uses centralized OpenSearch name auto-completion.
internal/opensearch/command/delete.go Uses centralized OpenSearch name auto-completion.
internal/opensearch/command/update.go Uses centralized OpenSearch name auto-completion.
internal/secret/command/command.go Refactors secret name autocompletion to support environment filtering and better messages.
internal/secret/command/environment.go Adds environment resolution logic for secrets get and validation for single -e/--environment usage.
internal/secret/command/environment_test.go Adds unit tests for secret environment selection behavior.
internal/secret/command/get.go Allows secrets get to resolve environment automatically; refactors logic into runGetCommand.
internal/secret/command/set.go Enforces single -e/--environment usage; updates autocompletion call signature.
internal/secret/command/unset.go Enforces single -e/--environment usage; updates autocompletion call signature.
internal/secret/command/delete.go Enforces single -e/--environment usage; updates autocompletion call signature.
internal/secret/command/activity.go Uses CLI-provided environment values when repeated -e flags are used.
internal/cliflags/flags.go Introduces helpers to extract/count flag values directly from argv.
internal/cliflags/flags_test.go Adds unit tests for the new argv flag helpers.
internal/app/command/activity.go Reads repeated environment flags from argv when needed for activity auto-complete.
internal/app/command/list.go Adds an autocomplete handler to provide an active-help message when team is missing.
internal/job/command/activity.go Reads repeated environment flags from argv when needed for activity auto-complete.
internal/job/command/list.go Adds an autocomplete handler to provide an active-help message when team is missing.
internal/application/application.go Registers valkey and opensearch as top-level commands.
internal/alpha/command/alpha.go Removes valkey and opensearch from the alpha command group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors CLI auto-completion and environment handling across several commands, introduces shared CLI-arg flag parsing helpers, and promotes the valkey and opensearch command groups from the alpha command tree into the main application command set.

Changes:

  • Centralize and enhance auto-completion for Valkey/OpenSearch/Secrets with team/environment-aware filtering and clearer user guidance.
  • Add internal/cliflags helpers for parsing repeated short/long flags from raw CLI args, plus unit tests.
  • Improve secrets get by resolving environment automatically when omitted (and add tests), and wire new commands into the main app while removing them from alpha.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Switch Valkey name autocomplete to shared helper.
internal/valkey/command/get.go Switch Valkey name autocomplete to shared helper.
internal/valkey/command/delete.go Switch Valkey name autocomplete to shared helper.
internal/valkey/command/command.go Add Valkey autocomplete helper and CLI env-flag parsing.
internal/valkey/command/flag/flag.go Migrate Valkey flags to embed GlobalFlags instead of alpha flags.
internal/opensearch/command/update.go Switch OpenSearch name autocomplete to shared helper.
internal/opensearch/command/get.go Switch OpenSearch name autocomplete to shared helper.
internal/opensearch/command/delete.go Switch OpenSearch name autocomplete to shared helper.
internal/opensearch/command/command.go Add OpenSearch autocomplete helper and CLI env-flag parsing.
internal/opensearch/command/flag/flag.go Migrate OpenSearch flags to embed GlobalFlags instead of alpha flags.
internal/secret/command/unset.go Enforce single environment flag usage + updated secret-name autocomplete call.
internal/secret/command/set.go Enforce single environment flag usage + updated secret-name autocomplete call.
internal/secret/command/get.go Resolve secret environment when omitted; refactor execution into helper function.
internal/secret/command/environment.go Add environment resolution + environment-flag usage validation utilities.
internal/secret/command/environment_test.go Unit tests for environment selection logic.
internal/secret/command/delete.go Enforce single environment flag usage + updated secret-name autocomplete call.
internal/secret/command/command.go Add environment-aware secret-name autocomplete + improved messaging.
internal/secret/command/activity.go Support environment filtering in secret-name autocomplete for activity.
internal/job/command/list.go Add autocomplete-time guidance when team is missing.
internal/job/command/activity.go Pull environment values from raw CLI args when flags aren’t populated (autocomplete).
internal/app/command/list.go Add autocomplete-time guidance when team is missing.
internal/app/command/activity.go Pull environment values from raw CLI args when flags aren’t populated (autocomplete).
internal/cliflags/flags.go New utilities to parse unique flag values and count occurrences from os.Args.
internal/cliflags/flags_test.go Unit tests for new CLI-flag parsing helpers.
internal/application/application.go Register Valkey and OpenSearch commands at the top-level app.
internal/alpha/command/alpha.go Remove Valkey/OpenSearch from alpha subcommands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CLI auto-completion and environment handling across several commands, and promotes valkey and opensearch from the alpha command group to top-level commands.

Changes:

  • Add internal/cliflags helpers to parse/count repeated CLI flags (notably --environment/-e) from os.Args.
  • Refactor secret/valkey/opensearch auto-completion to support environment filtering and clearer guidance when team/environment is missing or ambiguous.
  • Allow secret get to omit --environment by resolving the environment when the secret exists in exactly one environment; move valkey/opensearch to the root command set.

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Switch instance-name completion to shared autoCompleteValkeyNames.
internal/valkey/command/get.go Switch instance-name completion to shared autoCompleteValkeyNames.
internal/valkey/command/delete.go Switch instance-name completion to shared autoCompleteValkeyNames.
internal/valkey/command/command.go Add Valkey name auto-completion helper with env filtering + CLI flag parsing helpers.
internal/valkey/command/flag/flag.go Embed *flags.GlobalFlags instead of alpha flags.
internal/opensearch/command/update.go Switch instance-name completion to shared autoCompleteOpenSearchNames.
internal/opensearch/command/get.go Switch instance-name completion to shared autoCompleteOpenSearchNames.
internal/opensearch/command/delete.go Switch instance-name completion to shared autoCompleteOpenSearchNames.
internal/opensearch/command/command.go Add OpenSearch name auto-completion helper with env filtering + CLI flag parsing helpers.
internal/opensearch/command/flag/flag.go Embed *flags.GlobalFlags instead of alpha flags.
internal/secret/command/unset.go Enforce single --environment/-e usage; update secret name auto-completion signature.
internal/secret/command/set.go Enforce single --environment/-e usage; update secret name auto-completion signature.
internal/secret/command/delete.go Enforce single --environment/-e usage; update secret name auto-completion signature.
internal/secret/command/get.go Allow omitted environment via resolution; refactor run logic into runGetCommand; update auto-completion.
internal/secret/command/activity.go Auto-complete secret names filtered by selected/enumerated environments.
internal/secret/command/command.go Refactor secret-name auto-completion to support env filtering and improved messaging.
internal/secret/command/environment.go Add environment resolution + single-environment flag validation utilities.
internal/secret/command/environment_test.go Add tests for secret environment selection logic.
internal/job/command/list.go Add AutoCompleteFunc to provide a helpful “missing team” message.
internal/job/command/activity.go Use cliflags.UniqueFlagValues to infer environments from CLI args when none are set in flags.
internal/app/command/list.go Add AutoCompleteFunc to provide a helpful “missing team” message.
internal/app/command/activity.go Use cliflags.UniqueFlagValues to infer environments from CLI args when none are set in flags.
internal/cliflags/flags.go New helpers to parse unique flag values and count occurrences from raw CLI args.
internal/cliflags/flags_test.go Unit tests for cliflags parsing/counting behavior.
internal/application/application.go Register valkey and opensearch as top-level commands.
internal/alpha/command/alpha.go Remove valkey/opensearch from alpha subcommands.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR promotes the Valkey and OpenSearch commands from the alpha command group into the main CLI, and improves --environment/-e handling and auto-completion across several commands by parsing environment flags directly from CLI args.

Changes:

  • Add a new internal/cliflags helper package to parse/count CLI flag occurrences and values.
  • Improve environment validation/selection and environment-aware auto-completion for secrets, Valkey, OpenSearch, apps, and jobs.
  • Move valkey and opensearch commands out of alpha and into the main application command set.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/valkey/command/command.go Switch to GlobalFlags, add env-aware Valkey name auto-completion and single-env flag validation helpers.
internal/valkey/command/create.go Enforce single --environment/-e usage during validation.
internal/valkey/command/delete.go Use shared Valkey name auto-completion and enforce single environment flag usage.
internal/valkey/command/get.go Use shared Valkey name auto-completion and enforce single environment flag usage.
internal/valkey/command/update.go Use shared Valkey name auto-completion and enforce single environment flag usage.
internal/valkey/command/flag/flag.go Migrate Valkey flags to embed GlobalFlags instead of alpha flags.
internal/opensearch/command/command.go Switch to GlobalFlags, add env-aware OpenSearch name auto-completion and single-env flag validation helpers.
internal/opensearch/command/create.go Enforce single --environment/-e usage during validation.
internal/opensearch/command/delete.go Use shared OpenSearch name auto-completion and enforce single environment flag usage.
internal/opensearch/command/get.go Use shared OpenSearch name auto-completion and enforce single environment flag usage.
internal/opensearch/command/update.go Use shared OpenSearch name auto-completion and enforce single environment flag usage.
internal/opensearch/command/flag/flag.go Migrate OpenSearch flags to embed GlobalFlags instead of alpha flags.
internal/secret/command/command.go Refactor secret auto-completion to support environment filtering and better empty-result messaging.
internal/secret/command/environment.go Add logic to resolve/select environment for secrets and validate single env flag usage.
internal/secret/command/environment_test.go Add test coverage for secret environment selection logic.
internal/secret/command/get.go Allow secret get without explicit environment by resolving it when unambiguous; refactor run logic into helper.
internal/secret/command/set.go Enforce single --environment/-e usage; update auto-completion to new signature.
internal/secret/command/unset.go Enforce single --environment/-e usage; update auto-completion to new signature.
internal/secret/command/delete.go Enforce single --environment/-e usage; update auto-completion to new signature.
internal/secret/command/activity.go Auto-complete secret names with optional environment filtering sourced from CLI args.
internal/cliflags/flags.go Add utilities to parse unique flag values and count occurrences from os.Args.
internal/cliflags/flags_test.go Add tests for flag parsing/counting helpers.
internal/app/command/activity.go Use CLI-derived env values for name auto-completion when env flag list is empty.
internal/app/command/list.go Add an AutoCompleteFunc guard for missing team (currently introduces an unused param compile error).
internal/job/command/activity.go Use CLI-derived env values for name auto-completion when env flag list is empty.
internal/job/command/list.go Add an AutoCompleteFunc guard for missing team (currently introduces an unused param compile error).
internal/application/application.go Register valkey and opensearch commands in the main application command list.
internal/alpha/command/alpha.go Remove valkey and opensearch from the alpha command group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves CLI environment-flag handling and auto-completion behavior across multiple commands, while also promoting valkey and opensearch commands from the alpha command group into the main application command set.

Changes:

  • Add a shared cliflags helper for extracting/counting --environment/-e values from raw CLI args (supporting completion scenarios).
  • Update Valkey/OpenSearch/Secret commands to enforce single --environment/-e usage and to improve name auto-completion (including env filtering).
  • Enhance secret get to resolve environment automatically when not provided, with tests; move valkey/opensearch into the main app commands.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
internal/valkey/command/update.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/valkey/command/get.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/valkey/command/delete.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/valkey/command/create.go Enforce single env-flag usage during validation.
internal/valkey/command/command.go Switch to GlobalFlags; add env-aware Valkey name completion + env-flag parsing helpers.
internal/valkey/command/flag/flag.go Replace alpha flags embedding with GlobalFlags.
internal/opensearch/command/update.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/opensearch/command/get.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/opensearch/command/delete.go Enforce single env-flag usage; delegate name completion to shared helper.
internal/opensearch/command/create.go Enforce single env-flag usage during validation.
internal/opensearch/command/command.go Switch to GlobalFlags; add env-aware OpenSearch name completion + env-flag parsing helpers.
internal/opensearch/command/flag/flag.go Replace alpha flags embedding with GlobalFlags.
internal/secret/command/get.go Allow env omission by resolving secret environment; refactor into runGetCommand; update completion + validation.
internal/secret/command/set.go Enforce single env-flag usage; update secret-name completion signature.
internal/secret/command/unset.go Enforce single env-flag usage; update secret-name completion signature.
internal/secret/command/delete.go Enforce single env-flag usage; update secret-name completion signature.
internal/secret/command/command.go Add env-aware secret name completion with optional env filtering and better “no results” messages.
internal/secret/command/activity.go Update completion to support env filtering from flags/CLI args.
internal/secret/command/environment.go Add env resolution + single env-flag validation + CLI env extraction helpers.
internal/secret/command/environment_test.go Add unit tests for secret environment selection logic.
internal/app/command/activity.go Update completion to allow env values from CLI args when none are set in flags.
internal/app/command/list.go Add autocomplete messaging when team is missing.
internal/job/command/activity.go Update completion to allow env values from CLI args when none are set in flags.
internal/job/command/list.go Add autocomplete messaging when team is missing.
internal/cliflags/flags.go New helper: parse unique flag values and count occurrences from raw args.
internal/cliflags/flags_test.go Unit tests for CLI flag parsing/counting helpers.
internal/application/application.go Register valkey and opensearch as top-level commands.
internal/alpha/command/alpha.go Remove valkey/opensearch from alpha command group.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR promotes the valkey and opensearch command groups from alpha into the main CLI, and improves environment-related UX by (a) enforcing single --environment/-e usage where commands only accept one environment, and (b) making auto-completion environment-aware across several commands. It also updates app/job activity auto-completion to support multiple environment filters.

Changes:

  • Move valkey and opensearch commands out of alpha and register them in the main application command set.
  • Add shared CLI-args flag parsing helpers (internal/cliflags) and use them to support environment-aware auto-completion and to reject repeated --environment/-e where ambiguous.
  • Improve secret get behavior by resolving environment when omitted and adding tests for environment selection logic.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated no comments.

Show a summary per file
File Description
internal/valkey/command/update.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/valkey/command/get.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/valkey/command/delete.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/valkey/command/create.go Adds single-environment flag validation.
internal/valkey/command/command.go Moves to GlobalFlags parent, adds environment-aware instance name auto-completion + CLI-args parsing helpers.
internal/valkey/command/flag/flag.go Switches embedded flags from alpha.Alpha to flags.GlobalFlags.
internal/opensearch/command/update.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/opensearch/command/get.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/opensearch/command/delete.go Adds single-environment flag validation and switches name auto-completion to a shared helper.
internal/opensearch/command/create.go Adds single-environment flag validation.
internal/opensearch/command/command.go Moves to GlobalFlags parent, adds environment-aware instance name auto-completion + CLI-args parsing helpers.
internal/opensearch/command/flag/flag.go Switches embedded flags from alpha.Alpha to flags.GlobalFlags.
internal/secret/command/unset.go Adds single-environment flag validation and updates secret-name auto-completion signature.
internal/secret/command/set.go Adds single-environment flag validation and updates secret-name auto-completion signature.
internal/secret/command/delete.go Adds single-environment flag validation and updates secret-name auto-completion signature.
internal/secret/command/get.go Allows environment omission by resolving it at runtime; refactors execution into runGetCommand.
internal/secret/command/command.go Implements environment-aware secret-name auto-completion (including multi-env variant) and improved messaging.
internal/secret/command/activity.go Updates auto-completion to optionally filter by one or more environments.
internal/secret/command/environment.go Adds environment resolution/selection logic and CLI env-flag counting helpers.
internal/secret/command/environment_test.go Adds unit tests for environment selection logic.
internal/job/command/list.go Adds a minimal autocomplete handler to surface missing-team guidance.
internal/job/command/activity.go Updates job-name auto-completion to accept multiple environments from flags or CLI args.
internal/app/command/list.go Adds a minimal autocomplete handler to surface missing-team guidance.
internal/app/command/activity.go Updates application-name auto-completion to accept multiple environments from flags or CLI args.
internal/cliflags/flags.go New helpers to parse repeated flag occurrences/values directly from raw CLI args.
internal/cliflags/flags_test.go Unit tests for cliflags parsing behavior.
internal/application/application.go Registers valkey and opensearch at the top-level command set.
internal/alpha/command/alpha.go Removes valkey and opensearch from the alpha command group.
Comments suppressed due to low confidence (1)

internal/secret/command/get.go:52

  • secret get no longer validates --environment/-e when it is provided (the previous validation.CheckEnvironment call was removed). This means a typoed/invalid environment will only fail later (or give a misleading “secret does not exist in environment …” message). Suggest: if string(f.Environment) != "", run validation.CheckEnvironment(...) in ValidateFunc (keeping environment optional overall).
		ValidateFunc: func(_ context.Context, args *naistrix.Arguments) error {
			if err := validateSingleEnvironmentFlagUsage(); err != nil {
				return err
			}
			if err := validateArgs(args); err != nil {
				return err
			}
			if f.Reason != "" && !f.WithValues {
				return fmt.Errorf("--reason can only be used together with --with-values")
			}
			if f.WithValues && f.Reason != "" && len(f.Reason) < 10 {
				return fmt.Errorf("reason must be at least 10 characters")
			}
			return nil

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@rbjornstad rbjornstad marked this pull request as ready for review March 16, 2026 12:04
@rbjornstad rbjornstad merged commit 7e8004a into main Mar 16, 2026
19 checks passed
@rbjornstad rbjornstad deleted the feat/autocomplete-consistency branch March 16, 2026 12:04
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.

2 participants