totara / totara-docker-dev

A docker setup to create a development environment for Totara Learn
MIT License
49 stars 32 forks source link

Add tphp command #233

Closed scq closed 2 months ago

scq commented 1 year ago

This PR adds a tphp command for executing commands inside the php container.

Example:

sc ~/c/t/learn> tdb drop
Successfully dropped pgsql14 database learn_17
sc ~/c/t/learn> tdb create
Successfully created pgsql14 database learn_17
sc ~/c/t/learn> tphp install
Using PHP Container: php-8.1
Running Command: php server/admin/cli/install_database.php --adminpass=admin --adminemail=admin@example.com --agree-license --shortname=Totara 17 development site --fullname=Totara 17 development site
Totara 17.0+ (Build: 20221108.00) command line installation program
-------------------------------------------------------------------------------
== Setting up database ==
-->System
++ Success ++
-->totara_core
++ Success ++

This makes it a bit more convenient to use the install/cron/purge/etc aliases without needing to tbash in to the container.

scq commented 1 year ago

I've been using it locally for a while and discovered some issues with handling of args recently, will just convert it to a draft until I fix those

derschatta commented 3 months ago

I've been using it locally for a while and discovered some issues with handling of args recently, will just convert it to a draft until I fix those

Hey @scq how far are you away from converting this back to a regular merge request and get it in? Would be a great addition.

scq commented 3 months ago

@derschatta I still need to solve the issue with passing arguments -- it will fail if it gets passed arguments that are too complex. I'll try and take a look at this again to get that working :D

scq commented 3 months ago

Fixed the issues. Bash is currently broken though, so it needs #282 first.

Things you can do:

It autodetects if the first argument ends in .php and adds php on to the beginning, because I found that I kept leaving it off (and tphp php ... looks a little weird)

scq commented 3 months ago

Changed INTERACTIVE_SHELL default to zsh, seems like hardly anybody is using bash given #282

derschatta commented 3 months ago

There must be something specific needed for MacOS as I get:

/Users/username/folder/totara/docker/bin/tphp: line 13: ${i@Q}: bad substitution

when I try to use the command.

scq commented 3 months ago

Oh weird. I think Apple ships an ancient bash version that doesn't seem to support that parameter expansion syntax, will see if I can find another way to do it (the @Q is needed to quote the parameter).

scq commented 3 months ago

@derschatta okay, that should be fixed now