From 29b668b83d5be0be6034e9161e3629e7fad6fdf1 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Thu, 12 Jul 2012 00:30:04 +0200 Subject: [PATCH 1/3] added help:commands task to artisan --- laravel/cli/dependencies.php | 12 ++++++ laravel/cli/tasks/help.json | 78 ++++++++++++++++++++++++++++++++++++ laravel/cli/tasks/help.php | 35 ++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 laravel/cli/tasks/help.json create mode 100644 laravel/cli/tasks/help.php diff --git a/laravel/cli/dependencies.php b/laravel/cli/dependencies.php index f0c59e81..2e7f23b6 100644 --- a/laravel/cli/dependencies.php +++ b/laravel/cli/dependencies.php @@ -125,4 +125,16 @@ { return new Tasks\Bundle\Providers\Github; }); +} + +/** + * The "help" task provides information about + * artisan usage. + */ +if(! IoC::registered('task: help')) +{ + IoC::singleton('task: help', function() + { + return new Tasks\Help; + }); } \ No newline at end of file diff --git a/laravel/cli/tasks/help.json b/laravel/cli/tasks/help.json new file mode 100644 index 00000000..69e16fe6 --- /dev/null +++ b/laravel/cli/tasks/help.json @@ -0,0 +1,78 @@ +{ + "Application Configuration": { + "key:generate": { + "description": "Generate a secure application key.", + "command": "php artisan key:generate" + } + }, + "Database Tables": { + "session:table": { + "description": "Generate a migration for the sessions database table.", + "command": "php artisan session:table" + } + }, + "Migrations": { + "migrate:install": { + "description": "Create the Laravel migration table.", + "command": "php artisan migrate:install" + }, + "migrate:make": { + "description": "Create a migration.", + "command": "php artisan migrate:make create_users_table" + }, + "migrate": { + "description": "Run outstanding migrations.", + "command": "php artisan migrate" + }, + "migrate:rollback": { + "description": "Roll back the most recent migration.", + "command": "php artisan migrate:rollback" + }, + "migrate:reset": { + "description": "Roll back all migrations.", + "command": "php artisan migrate:reset" + } + }, + "Bundles": { + "bundle:install": { + "description": "Install a bundle.", + "command": "php artisan bundle:install swiftmailer" + }, + "bundle:upgrade": { + "description": "Upgrade a bundle.", + "command": "php artisan bundle:upgrade swiftmailer" + }, + "bundle:publish": { + "description": "Publish all bundles' assets.", + "command": "php artisan bundle:publish" + } + }, + "Unit Tests": { + "test": { + "description": "Run the application's tests.", + "command": "php artisan test" + } + }, + "Routing": { + "route:call": { + "description": "Call a route.", + "command": "php artisan route:call get api/user/1" + } + }, + "Application Keys": { + "key:generate": { + "description": "Generate an application key.", + "command": "php artisan key:generade" + } + }, + "CLI Options": { + "--env=": { + "description": "Set the Laravel environment.", + "command": "php artisan task --env=local" + }, + "--database=": { + "description": "Set the default database connection.", + "command": "php artisan task --database=mysql" + } + } +} \ No newline at end of file diff --git a/laravel/cli/tasks/help.php b/laravel/cli/tasks/help.php new file mode 100644 index 00000000..5add2e75 --- /dev/null +++ b/laravel/cli/tasks/help.php @@ -0,0 +1,35 @@ + $commands) + { + + if($i++ != 0) echo PHP_EOL; + + echo PHP_EOL . "# $category" . PHP_EOL; + + foreach($commands as $command => $details) + { + echo PHP_EOL . str_pad($command, 20) . str_pad($details->description, 30); + } + } + } + +} \ No newline at end of file From 644ecfcc2586add3143f73a02f7411876a018b7d Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Thu, 12 Jul 2012 13:00:35 +0200 Subject: [PATCH 2/3] adding basic help functions to artisan --- laravel/cli/tasks/help.php | 1 - 1 file changed, 1 deletion(-) diff --git a/laravel/cli/tasks/help.php b/laravel/cli/tasks/help.php index 5add2e75..e81bc945 100644 --- a/laravel/cli/tasks/help.php +++ b/laravel/cli/tasks/help.php @@ -31,5 +31,4 @@ public function commands() } } } - } \ No newline at end of file From 7dcbf33a80017276b034ce93b9f002a2f7ce18a2 Mon Sep 17 00:00:00 2001 From: Shawn McCool Date: Mon, 16 Jul 2012 10:28:40 +0200 Subject: [PATCH 3/3] cleaned up help task --- laravel/cli/tasks/help.json | 2 +- laravel/cli/tasks/help.php | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/laravel/cli/tasks/help.json b/laravel/cli/tasks/help.json index 69e16fe6..3f614ad1 100644 --- a/laravel/cli/tasks/help.json +++ b/laravel/cli/tasks/help.json @@ -47,7 +47,7 @@ "command": "php artisan bundle:publish" } }, - "Unit Tests": { + "Unit Testing": { "test": { "description": "Run the application's tests.", "command": "php artisan test" diff --git a/laravel/cli/tasks/help.php b/laravel/cli/tasks/help.php index e81bc945..8cfcd768 100644 --- a/laravel/cli/tasks/help.php +++ b/laravel/cli/tasks/help.php @@ -6,21 +6,22 @@ class Help extends Task { /** - * List + * List available artisan commands. * * @param array $arguments * @return void */ public function commands() { + // read help contents - $command_data = json_decode(file_get_contents(__DIR__.'/help.json')); + $command_data = json_decode(File::get(__DIR__.'/help.json')); + + // format and display help contents $i=0; - foreach($command_data as $category => $commands) { - if($i++ != 0) echo PHP_EOL; echo PHP_EOL . "# $category" . PHP_EOL;