wckr / wocker

Create your WordPress development environment in 3 SECONDS!
https://wocker.dev/
MIT License
480 stars 42 forks source link

wocker wp db reset #45

Closed ivillacreative closed 6 years ago

ivillacreative commented 8 years ago

When attempting to reset the wordpress database using WP-CLI, I get an error when trying to confirm [y/n].

ailispaw commented 8 years ago

I'm not sure it is related to your problem, but I found a bug at https://github.com/wckr/wocker-cli/blob/master/wocker#L370.

--- wocker
+++ wocker.patched
@@ -367,7 +367,7 @@
         cid=$(docker ps -q)
         if [[ ! $cid =~ $'\n' ]]; then
           if [[ "$2" = 'shell' ]]; then
-            docker exec -u $USER -it $cid wp ${@:2}
+            docker exec -u $USER -it $cid wp ${@:3}
           else
             docker exec -u $USER $cid wp ${@:2}
           fi
wocker ~ $ wocker wp shell db reset
Are you sure you want to reset the database? [y/n] y
Success: Database reset.
ailispaw commented 8 years ago

Ah. It's not a bug. My above patch is not good for the shell subcommand itself. Sorry. I thought the shell was the keyword for an interactive mode, but a subcommand.

ailispaw commented 8 years ago

Revised the patch.

--- wocker
+++ wocker.patched
@@ -366,11 +366,7 @@
       if [[ $(docker ps -q) ]]; then
         cid=$(docker ps -q)
         if [[ ! $cid =~ $'\n' ]]; then
-          if [[ "$2" = 'shell' ]]; then
-            docker exec -u $USER -it $cid wp ${@:2}
-          else
-            docker exec -u $USER $cid wp ${@:2}
-          fi
+          docker exec -u $USER -it $cid wp ${@:2}
         fi
       fi
     fi
wocker ~ $ wocker wp db reset
Are you sure you want to reset the database? [y/n] y
Success: Database reset.
ailispaw commented 8 years ago

My patch may be not good for other subcommands. The commands which have interactive mode are shell and db only?

ailispaw commented 8 years ago

BTW, after db reset, I got an error.

Error: The site you have requested is not installed.
Run `wp core install`.
ivillacreative commented 8 years ago

I looked up the WP-CLI docs, you can get passed the [y/n] by adding a '--yes' flag.

so this would work wocker ~ $ wocker wp db reset --yes

ailispaw commented 8 years ago

Yes, it does with the original wocker-cli. So what is your problem exactly?

ailispaw commented 8 years ago

Anyway the current wocker wp command doesn't work well with an interactive mode except shell.

ivillacreative commented 8 years ago

well using the flag seems to solve this problem of not being able to get passed the [y/n] confirmation WP-CLI asked for.

and I do agree about wocker wp

ailispaw commented 8 years ago

I see. Thank you for the clarification. Ping @ixkaito

ixkaito commented 8 years ago

Thank you both @ivanvillacreative @ailispaw . I'll find a better solution about this issue.

ixkaito commented 6 years ago

Fixed.