Skip to content

Commit

Permalink
get commands from config
Browse files Browse the repository at this point in the history
  • Loading branch information
Recca Tsai committed Sep 13, 2016
1 parent 49c283b commit 8f3fe43
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 24 deletions.
41 changes: 19 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Add Presenter to your composer.json file:

```js
"require": {
"recca0120/terminal": "^1.5.1"
"recca0120/terminal": "^1.6.0"
}
```
Now, run a composer update on the command line from the root of your project:
Expand Down Expand Up @@ -54,11 +54,21 @@ http://localhost/path/to/terminal
return [
'enabled' => true,
'whitelists' => ['127.0.0.1', 'your ip'],
'router' => [
'route' => [
'prefix' => 'terminal',
'as' => 'terminal.',
'middleware' => ['web'], // if you use laravel 5.1 remove web
],
'commands' => [
\Recca0120\Terminal\Console\Commands\Artisan::class,
\Recca0120\Terminal\Console\Commands\ArtisanTinker::class,
\Recca0120\Terminal\Console\Commands\Cleanup::class,
\Recca0120\Terminal\Console\Commands\Find::class,
\Recca0120\Terminal\Console\Commands\Mysql::class,
\Recca0120\Terminal\Console\Commands\Tail::class,
\Recca0120\Terminal\Console\Commands\Vi::class,
// add your command
],
];

```
Expand Down Expand Up @@ -117,26 +127,6 @@ class Inspire extends Command
}
```

### Add Command
```php
// src/Console/Kernel.php
namespace Recca0120\Terminal\Console;

use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Recca0120\Terminal\Console\Application as Artisan;

class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
Commands\Inspire::class,
];
}

```
## ScreenShot
Expand Down Expand Up @@ -164,6 +154,13 @@ $ artisan tinker
```
![Tinker](https://cdn.rawgit.com/recca0120/terminal/master/screenshots/artisan-tinker.png)

### MySQL
```bash
$ mysql
mysql> select * from users;
```
![MySQL Command](https://cdn.rawgit.com/recca0120/terminal/master/screenshots/mysql-command.png)
### Find Command
```bash
$ find ./ -name * -maxdepth 1
Expand Down
Binary file added screenshots/mysql-command.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function register()
$this->mergeConfigFrom(__DIR__.'/../config/terminal.php', 'terminal');
$this->app->singleton(Application::class, function ($app) {
$config = $app['config'];
$commands = Arr::get($config, 'terminal.commands');
$commands = $config->get('terminal.commands');
$artisan = new Application($app, $app['events'], $app->version());
$artisan->resolveCommands($commands);

Expand Down
3 changes: 2 additions & 1 deletion tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function test_boot()
->shouldReceive('get')->with('terminal', [])->twice()->andReturn([
'whitelists' => ['127.0.0.1'],
])
->shouldReceive('set')->with('terminal', m::any())->once();
->shouldReceive('set')->with('terminal', m::any())->once()
->shouldReceive('get')->with('terminal.commands')->once()->andReturn([]);

$request
->shouldReceive('getClientIp')->once()->andReturn('127.0.0.1');
Expand Down

0 comments on commit 8f3fe43

Please sign in to comment.