mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 05:44:04 +00:00
Write docs, add support for = in arg/opt value
This commit is contained in:
parent
5e34c2c6a4
commit
ccba8e43dc
3 changed files with 17 additions and 8 deletions
14
README.md
14
README.md
|
|
@ -53,6 +53,7 @@ You won't have to change a thing in your application's code.\*
|
||||||
* [Artisan commands](#artisan-commands)
|
* [Artisan commands](#artisan-commands)
|
||||||
- [`tenants:list`](#-tenants-list-)
|
- [`tenants:list`](#-tenants-list-)
|
||||||
- [`tenants:migrate`, `tenants:rollback`, `tenants:seed`](#-tenants-migrate----tenants-rollback----tenants-seed-)
|
- [`tenants:migrate`, `tenants:rollback`, `tenants:seed`](#-tenants-migrate----tenants-rollback----tenants-seed-)
|
||||||
|
- [Running your commands for tenants](#running-your-commands-for-tenants)
|
||||||
+ [Tenant migrations](#tenant-migrations)
|
+ [Tenant migrations](#tenant-migrations)
|
||||||
- [Tips](#tips)
|
- [Tips](#tips)
|
||||||
* [HTTPS certificates](#https-certificates)
|
* [HTTPS certificates](#https-certificates)
|
||||||
|
|
@ -485,6 +486,7 @@ Available commands for the "tenants" namespace:
|
||||||
tenants:list List tenants.
|
tenants:list List tenants.
|
||||||
tenants:migrate Run migrations for tenant(s)
|
tenants:migrate Run migrations for tenant(s)
|
||||||
tenants:rollback Rollback migrations for tenant(s).
|
tenants:rollback Rollback migrations for tenant(s).
|
||||||
|
tenants:run Run a command for tenant(s).
|
||||||
tenants:seed Seed tenant database(s).
|
tenants:seed Seed tenant database(s).
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -507,6 +509,18 @@ Tenant: 8075a580-1cb8-11e9-8822-49c5d8f8ff23 (laravel.localhost)
|
||||||
Database seeding completed successfully.
|
Database seeding completed successfully.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Running your commands for tenants
|
||||||
|
|
||||||
|
You can use the `tenants:run` command to run your own commands for tenants.
|
||||||
|
|
||||||
|
If your command's signature were `email:send {user} {--queue} {--subject} {body}`, you would run this command like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
artisan tenants:run email:send --tenants=8075a580-1cb8-11e9-8822-49c5d8f8ff23 --option="queue=1" --option="subject=New Feature" --argument="body=We have launched a new feature. ..."
|
||||||
|
```
|
||||||
|
|
||||||
|
The `=` separates the argument/option name from its value, but you can still use `=` in the argument's value.
|
||||||
|
|
||||||
### Tenant migrations
|
### Tenant migrations
|
||||||
|
|
||||||
Tenant migrations are located in `database/migrations/tenant`, so you should move your tenant migrations there.
|
Tenant migrations are located in `database/migrations/tenant`, so you should move your tenant migrations there.
|
||||||
|
|
|
||||||
|
|
@ -41,17 +41,17 @@ class Run extends Command
|
||||||
|
|
||||||
$callback = function ($prefix = '') {
|
$callback = function ($prefix = '') {
|
||||||
return function ($arguments, $argument) use ($prefix) {
|
return function ($arguments, $argument) use ($prefix) {
|
||||||
[$key, $value] = explode('=', $argument);
|
[$key, $value] = explode('=', $argument, 2);
|
||||||
$arguments[$prefix . $key] = $value;
|
$arguments[$prefix . $key] = $value;
|
||||||
|
|
||||||
return $arguments;
|
return $arguments;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Turns ['foo=bar', 'abc=xyz'] into ['foo' => 'bar', 'abc' => 'xyz']
|
// Turns ['foo=bar', 'abc=xyz=zzz'] into ['foo' => 'bar', 'abc' => 'xyz=zzz']
|
||||||
$arguments = array_reduce($this->option('argument'), $callback(), []);
|
$arguments = array_reduce($this->option('argument'), $callback(), []);
|
||||||
|
|
||||||
// Turns ['foo=bar', 'abc=xyz'] into ['--foo' => 'bar', '--abc' => 'xyz']
|
// Turns ['foo=bar', 'abc=xyz=zzz'] into ['--foo' => 'bar', '--abc' => 'xyz=zzz']
|
||||||
$options = array_reduce($this->option('option'), $callback('--'), []);
|
$options = array_reduce($this->option('option'), $callback('--'), []);
|
||||||
|
|
||||||
// Run command
|
// Run command
|
||||||
|
|
|
||||||
|
|
@ -107,13 +107,8 @@ class CommandsTest extends TestCase
|
||||||
$uuid = tenant()->create('run.localhost')['uuid'];
|
$uuid = tenant()->create('run.localhost')['uuid'];
|
||||||
|
|
||||||
Artisan::call('tenants:migrate', ['--tenants' => $uuid]);
|
Artisan::call('tenants:migrate', ['--tenants' => $uuid]);
|
||||||
<<<<<<< HEAD
|
|
||||||
|
|
||||||
$this->artisan("tenants:run foo --tenants=$uuid --argument='a=foo' --option='b=bar' --option='c=xyz'")
|
$this->artisan("tenants:run foo --tenants=$uuid --argument='a=foo' --option='b=bar' --option='c=xyz'")
|
||||||
=======
|
|
||||||
|
|
||||||
$this->artisan("tenants:run foo --tenants=$uuid a b")
|
|
||||||
>>>>>>> 1322d02c786f86c50878b63af3a37ec6079238d3
|
|
||||||
->expectsOutput("User's name is Test command")
|
->expectsOutput("User's name is Test command")
|
||||||
->expectsOutput('foo')
|
->expectsOutput('foo')
|
||||||
->expectsOutput('xyz');
|
->expectsOutput('xyz');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue