diff --git a/cli/cli.py b/cli/cli.py index feeb029..1b29d68 100644 --- a/cli/cli.py +++ b/cli/cli.py @@ -11,29 +11,6 @@ def choose_option() -> None: """ kuber: Kuber = Kuber() - print(f'You are connected to {kuber.show_active_context()}\n') - - questions = [ - inquirer.List( - 'option', - message="Is this the correct cluster? ", - choices=['Yes', - 'No', - 'Exit' - ], - ), - ] - answers: dict = inquirer.prompt(questions) - - match answers["option"]: - case "No": - print("Please connect to the right cluster and try again") - exit(0) - case "Yes": - pass - case "Exit": - exit(0) - questions = [ inquirer.List( 'option', @@ -47,6 +24,7 @@ def choose_option() -> None: ] answers: dict = inquirer.prompt(questions) click.echo(f'You chose: {answers["option"]}') + match answers["option"]: case "Exit": exit(0) @@ -91,4 +69,28 @@ def choose_namespace(ns_list: list) -> str: answers: dict = inquirer.prompt(questions) # click.echo(f'You chose: {answers["option"]}') - return answers["option"] \ No newline at end of file + return answers["option"] + +def show_connected_cluster(kuber) -> None: + print(f'You are connected to {kuber.show_active_context()}\n') + + questions = [ + inquirer.List( + 'option', + message="Is this the correct cluster? ", + choices=['Yes', + 'No', + 'Exit' + ], + ), + ] + answers: dict = inquirer.prompt(questions) + + match answers["option"]: + case "No": + print("Please connect to the right cluster and try again") + exit(0) + case "Yes": + pass + case "Exit": + exit(0) \ No newline at end of file diff --git a/main.py b/main.py index 06cf2fa..3e5c4c9 100755 --- a/main.py +++ b/main.py @@ -12,6 +12,7 @@ if __name__ == '__main__': Kuber.load_kube_config() + cli.show_connected_cluster(kuber=Kuber()) cli.choose_option()