platformsh / legacy-cli

This is the legacy version of Platform.sh's command-line interface. The new version is at: https://github.com/platformsh/cli
https://docs.platform.sh/administration/cli.html
MIT License
224 stars 121 forks source link

var:create prompts for environment when -e option is present #1002

Open royallthefourth opened 3 years ago

royallthefourth commented 3 years ago

When creating a new env var with the -e option, I expect that environment to be used. Instead, the CLI tool prompts interactively. A command like this one should contain all the information needed to create an environment variable without prompts: platform var:create -l environment -e master --json=false --sensitive=false --enabled=true --inheritable=false -p PROJECT --value=VALUE VAR_NAME

pjcdawkins commented 3 years ago

I've looked into this and it's sort of deliberate. The -e master ends up being the default for the environment prompt. In interactive mode a prompt is still displayed. In non-interactive mode (-y) then defaults will be chosen and no prompts shown.

So there's an easy way to avoid prompts - use -y. But I see the behavior clashes a bit with the expectation in most commands, that -e has the highest priority for choosing the environment.

drjayvee commented 3 years ago

One problem with the -y workaround is that it applies to all options (e.g., --json, --visible-runtime, etc).

If I use -y to "enforce" -e production (we don't use "master" at all) and forget one of the other switches, the CLI will use its default when I'd rather get a prompt.

pjcdawkins commented 1 year ago

@royallthefourth @drjayvee thanks for your feedback over the last 2 years :) You may be interested in the two PRs:

pjcdawkins commented 1 year ago

For some more clarification: -y does not apply to --json/--visible-runtime, etc., those are true or false value questions not confirmation questions (see #1054 and 42472e8b2b3c8c57f86243611e9cb077405e0327/https://github.com/platformsh/console-form/commit/f3466e24ad6f61f7a8d7fee00bef5b546eea98ef)