diff --git a/README.md b/README.md index fc82ba8..d0e37e7 100644 --- a/README.md +++ b/README.md @@ -16,20 +16,21 @@ composer require --dev laravel-fans/lint php artisan lint:publish ``` -## use +## usage -lint code: +### lint code ```shell -php artisan lint:check . -php artisan lint:check app/ tests/ -php artisan lint:check --standard=Squiz app/ +php artisan lint:code +php artisan lint:code --fix +php artisan lint:code app/ tests/ +php artisan lint:code --standard=Squiz app/ php artisan lint:staged ``` -The default standard is PSR-12, feel free to change the `phpcs.xml`. +The default standard is `phpcs.xml`, feel free to change it. -lint route URL: +### lint route URI ```shell php artisan lint:route diff --git a/src/LintCodeCommand.php b/src/LintCodeCommand.php index 4329bc7..16b2ac6 100644 --- a/src/LintCodeCommand.php +++ b/src/LintCodeCommand.php @@ -14,7 +14,7 @@ class LintCodeCommand extends Command * @var string */ protected $signature = 'lint:code - {files*} + {files?*} {--fix : automatic fix} {--standard=phpcs.xml : coding standards}'; @@ -33,9 +33,11 @@ class LintCodeCommand extends Command public function handle() { $bin = $this->option('fix') ? 'phpcbf' : 'phpcs'; + $files = empty($this->argument('files')) ? [ '.' ] : $this->argument('files'); + exec( "vendor/bin/$bin --standard=" . $this->option('standard') - . ' ' . implode(' ', $this->argument('files')), + . ' ' . implode(' ', $files), $output, $code );