diff --git a/enabler/cli.py b/enabler/cli.py index ea7e2be..7daf21b 100644 --- a/enabler/cli.py +++ b/enabler/cli.py @@ -1,8 +1,20 @@ import os import logging - import click import click_log +import subprocess + + +class CLI: + def __init__(self, runner): + self.runner = runner + + def version_command(self): + try: + result = subprocess.run(['enabler', 'version'], capture_output=True, text=True, check=True) # noqa + return result.stdout.strip() + except subprocess.CalledProcessError as e: + raise RuntimeError(f"Failed to get version: {e}") CONTEXT_SETTINGS = dict(auto_envvar_prefix="ENABLER") diff --git a/enabler/commands/enabler_completion.sh b/enabler/commands/enabler_completion.sh index b761d59..80853f8 100755 --- a/enabler/commands/enabler_completion.sh +++ b/enabler/commands/enabler_completion.sh @@ -1,55 +1,30 @@ _enabler_complete() { - local cur_word prev_word commands + local cur_word prev_word # Get the current and previous words cur_word="${COMP_WORDS[COMP_CWORD]}" prev_word="${COMP_WORDS[COMP_CWORD-1]}" - local categories="apps kind preflight platform setup version" case "$prev_word" in "enabler") # noqa - commands="$categories" + COMPREPLY=( $(compgen -W "apps kind preflight platform setup version" -- "$cur_word") ) ;; - esac - - # Initialize the variable to store previous words - prev_words="" - local apps="namespace" - local kind="create delete status start stop" - local platform="init info keys release version" - local setup="init metallb istio" - - # Loop through previous words and concatenate them - for ((i=1; i