cli icon indicating copy to clipboard operation
cli copied to clipboard

Commands should support --non-interactive or --yes option

Open hnykda opened this issue 1 year ago • 5 comments

Is your feature request related to a problem? Please describe. I want to run e.g. supabase db reset inside CI. It asks for confirmation, making it unusable. Also discussed here.

Describe the solution you'd like I want a switch such as other tools have, i.e. apt-get --assume-yes or pacman -Syu --no-confirm so the CLI command doesn't ask me anything and do its job. For example, I want supabase db reset --linked --assume-yes

Describe alternatives you've considered

$ yes | supabase db reset --linked

but that recently started to fail with:

yes: standard output: Broken pipe

so we have this esoteric approach instead:

      - name: Create and run expect script
        run: |
          sudo apt-get install -y expect
          echo '#!/usr/bin/expect -f' > reset_db.exp
          echo 'spawn supabase db reset --linked' >> reset_db.exp
          echo 'expect {*Do you want to reset the remote database*} { send "y\r" }' >> reset_db.exp
          echo 'expect eof' >> reset_db.exp
          chmod +x reset_db.exp
          ./reset_db.exp

hnykda avatar May 29 '24 15:05 hnykda

That seems to be a limitation with yes https://stackoverflow.com/questions/20573282/hudson-yes-standard-output-broken-pipe I will look into adding the non-interactive flag.

Meanwhile, another alternative is to use here-string

supabase db reset --linked <<< 'y'

sweatybridge avatar May 29 '24 15:05 sweatybridge

Thank you, that works ❤️

hnykda avatar May 29 '24 16:05 hnykda

Adding a flag to run the all the CLI commands (not just db reset) in a non-interactive environment (e.g. Github actions) is a necessity. If you don't want to put a flag everywhere, then make it look at an environment variable like CI=1 and bypass the interaction in the prompt function.

rauljmz avatar Jun 06 '24 07:06 rauljmz

@rauljmz what specific problem are you facing? The prompts are already skipped using default answers on CI environments like GitHub action.

This specific issue is about answering yes (non-default option) to db reset.

sweatybridge avatar Jun 06 '24 11:06 sweatybridge

That seems to be a limitation with yes https://stackoverflow.com/questions/20573282/hudson-yes-standard-output-broken-pipe I will look into adding the non-interactive flag.

Meanwhile, another alternative is to use here-string

supabase db reset --linked <<< 'y'

The Here string solution was not working under node scripts so tinkering a bit I found that using the following it works

echo 'Y' | supabase db reset --linked

ghost avatar Oct 15 '24 17:10 ghost

it only works with "sh -c echo Y | supabase db reset --linked"

nrgyapp avatar Dec 16 '24 09:12 nrgyapp