Skip to content

Enabling Autocompletion for Custom CLI commands #438

Description

@RoseSecurity

Describe the Feature

Would it be possible to enable autocompletion for custom CLI parameters passed into atmos.yaml?

This would allow for adding a complete section to atmos.yaml so that custom commands can be autocompleted. An example of this would be by adding the following to atmos.yaml:

complete:
  enable: true
  fuzzyMatching: true

Where we could define completeFunctions to dynamically fetch data for autocompletion and attach functions to arguments/flags

# Functions to complete on
completeFunctions:
  - name: components
    exec:
      - atmos list components
    
# Attach to function
  - name: describe
    description: Execute 'describe' commands
    # subcommands
    commands:
      - name: k8s-upgrade
        description: "Describe the steps on how to upgrade an EKS cluster to the next Kubernetes version. Usage: atmos describe k8s-upgrade <eks_component> -s <stack>"
        arguments:
          - name: component
            description: Name of the EKS component
              complete:
                - components

Maybe this could be achieved by doing something similar to:

	if cfg.Complete.Enable {
		cobra.EnableCommandNameCompletion = true
		cobra.EnableCommandNameFuzzyMatching = cfg.Complete.AutoFuzzing
	}

Expected Behavior

An example command would be:

atmos describe component ...

where the ... would autocomplete

Use Case

This feature is just for ease of use and quality of life improvements.

Describe Ideal Solution

Whichever way is the easiest and most painless way to implement.

Alternatives Considered

Not sure if it is easier to incorporate into a custom atmos.yaml file.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions