stackitcloud / stackit-cli

A command-line interface to manage STACKIT resources
https://www.stackit.de/en
Apache License 2.0
35 stars 7 forks source link

Dont ask for OVERWRITE if the filepath does not exist #428

Open Slm0n87 opened 1 month ago

Slm0n87 commented 1 month ago

Doing:

➜  ~ rm .kube/custom-contexts/inttestv128.yaml
➜  ~ ll .kube/custom-contexts/inttestv128.yaml
ls: .kube/custom-contexts/inttestv128.yaml: No such file or directory
➜  ~ s ske kubeconfig create inttestv128 --filepath ~/.kube/custom-contexts/inttestv128.yaml
Are you sure you want to create a kubeconfig for SKE cluster "inttestv128"? This will OVERWRITE your current kubeconfig file, if it exists. [y/N] y
Created kubeconfig file for cluster inttestv128 in "/Users/stier/.kube/custom-contexts/inttestv128.yaml", with expiration date 2024-07-26T08:08:00Z (UTC)
➜  ~

The cli gives a warning to overwrite the config file if it exists and have a default: No. This is very nice, but absolut unnecessary if the file des not exist.

Expected behaviour: Just write the file and avoid unnecessary user interaction.

DiogoFerrao commented 1 month ago

Hey @Slm0n87 thank you once again for your feedback!

In commands that make changes (create, update, delete, etc), we have the common practice of asking the user for confirmation. This is also common behaviour in other CLI's and in programs in general. However, if you don't want to be prompted for confirmation you can always provide the --assume-yes flag, which will bypass the prompts and remove the user interaction from the command.

Kind regards, Diogo

Slm0n87 commented 1 month ago

Thx @DiogoFerrao, the --assume-yes helped me in that case.

I agree that its common behaviour and best practices for CLI's before overwriting existing files.
But I am not aware of any CLI where I explicitly specify a file as argument and I get prompted to confirm that I really want to save it there.

Regards, Simon

DiogoFerrao commented 1 month ago

That's a good point @Slm0n87, I think this is also one of the few commands that interact with files in the user's system and not STACKIT resources that come with costs.

We could consider having a check and only prompt the user for confirmation when actually overwriting a file. We will add this topic to the our backlog and keep you updated on its progress!