Skip to content

Commit dd8cc8b

Browse files
committed
check commands options are running and add description to readme file.
1 parent 2509fc2 commit dd8cc8b

File tree

4 files changed

+33
-19
lines changed

4 files changed

+33
-19
lines changed

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ Create new command file. The file will be saved in database/commands directory.
2929
php artisan make:deploy-command your_command_name
3030
```
3131

32-
Run new commands (Those which have not been started before).
33-
```
34-
php artisan deploy-commands:run
35-
```
3632
This will generate a command file `TIMESTAMP_your_command_name.php` in the `dabase/commands` directory.
3733
```php
3834
<?php
@@ -52,7 +48,27 @@ class YourCommandName extends Command
5248
}
5349
}
5450
```
55-
You can freely edit file at your discretion:)
51+
You can freely edit file at your discretion :)
52+
53+
Available options:
54+
```
55+
--path=
56+
```
57+
The location where the command file should be created.
58+
59+
Run new commands (Those which have not been started before).
60+
```
61+
php artisan deploy-commands:run
62+
```
63+
Available options:
64+
```
65+
--pretend
66+
```
67+
Dump the SQL queries that would be run.
68+
```
69+
--path=
70+
```
71+
The path of commands files to be executed. E.g. `--path=/commands/`.
5672
## TODO
5773
- clean code
5874
- write some tests

src/CommandRunner.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ protected function runCommand($file, $pretend)
211211
/**
212212
* Pretend to run the migrations.
213213
*
214-
* @param object $migration
214+
* @param object|Command $command
215215
* @param string $method
216216
* @return void
217217
*/
218-
protected function pretendToRun($migration, $method)
218+
protected function pretendToRun($command, $method)
219219
{
220-
foreach ($this->getQueries($migration, $method) as $query) {
221-
$name = get_class($migration);
220+
foreach ($this->getQueries($command, $method) as $query) {
221+
$name = get_class($command);
222222

223223
$this->note("<info>{$name}:</info> {$query['query']}");
224224
}
@@ -227,22 +227,20 @@ protected function pretendToRun($migration, $method)
227227
/**
228228
* Get all of the queries that would be run for a migration.
229229
*
230-
* @param object $migration
230+
* @param object|Command $command
231231
* @param string $method
232232
* @return array
233233
*/
234-
protected function getQueries($migration, $method)
234+
protected function getQueries($command, $method)
235235
{
236236
// Now that we have the connections we can resolve it and pretend to run the
237237
// queries against the database returning the array of raw SQL statements
238238
// that would get fired against the database system for this migration.
239-
$db = $this->resolveConnection(
240-
$migration->getConnection()
241-
);
239+
$db = $this->resolveConnection(null);
242240

243-
return $db->pretend(function () use ($migration, $method) {
244-
if (method_exists($migration, $method)) {
245-
$migration->{$method}();
241+
return $db->pretend(function () use ($command, $method) {
242+
if (method_exists($command, $method)) {
243+
$command->{$method}();
246244
}
247245
});
248246
}

src/Console/MakeCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MakeCommand extends BaseCommand
1414
* @var string
1515
*/
1616
protected $signature = 'make:deploy-command {name : The name of the command.}
17-
{--path= : The location where the migration file should be created.}';
17+
{--path= : The location where the command file should be created.}';
1818

1919
/**
2020
* The console command description.

src/Console/RunCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RunCommand extends BaseCommand
1212
* @var string
1313
*/
1414
protected $signature = 'deploy-commands:run {--database= : The database connection to use.}
15-
{--path= : The path of migrations files to be executed.}
15+
{--path= : The path of commands files to be executed.}
1616
{--pretend : Dump the SQL queries that would be run.}';
1717

1818
/**

0 commit comments

Comments
 (0)