Work around prompts/dialogs in automated environments

A lot of Fly commands don’t provide a flag (such as --yes) to skip prompts, fill dialogs etc. in advance, which makes them hard to use in automated environments such as GitHub workflows/CD. I’ve already opened an issue on this via GitHub, but I’d be curious to know if anyone here has an idea how to work around this limitation. I tried feeding stdin with the following commands:

  • printf '%s' 'y' | fly ...
  • echo -ne 'y' | fly ...
  • Using a heredoc:
  $ fly ... <<EOF
  y
  EOF

But to no success; Fly always complains: (unlike other command-line utilities)

$ echo "y" | fly postgres connect --app myapp-2
WARN app flag 'myapp-2' does not match app name in config file 'myapp'
? Continue using 'myapp' (y/N)                              Error EOF
^[[24;120R^[[24;120R%

(In the example above, I’d like to automatically confirm the prompt, execute some SQL commands on the cluster, and close the connection again, from a provided string automatically - the psql cli can do this, fly apparently cannot)

Does anyone have an idea on what to do about this? It’s quite frustrating to have to run these commands manually atm (since fly doesn’t provide a proper GitHub integration in the first place)

1 Like