diff --git a/README.md b/README.md index aec1445..58b2d83 100644 --- a/README.md +++ b/README.md @@ -90,15 +90,16 @@ $ ln -s /path/to/phpqa/bin/phpqa /usr/local/bin/phpqa ### Copy configuration file(s) ``` $ cd to/project/path -$ phpqa init --project=PROJECT --dir=DIR --override +$ phpqa init --project=PROJECT --global --override ``` | Option | Description | | -------- | ----------------------------- | | project | Available values `php`, `symfony` and `drupal`. | -| dir | Available values `home`, `current`. | +| global | Copy configuration files to user home directory, instead of current working directory. | | override | If this option is set, files are copied using override flag. | **NOTES:** +- Option `global` does not accept a value must be set as `--global`. - Option `override` does not accept a value must be set as `--override`. ### Analyze a project diff --git a/src/Command/InitCommand.php b/src/Command/InitCommand.php index fad6a6f..38c2f94 100644 --- a/src/Command/InitCommand.php +++ b/src/Command/InitCommand.php @@ -52,15 +52,6 @@ protected function configure() $this ->setName('init') ->setDescription('Copy configuration files to user home directory') - ->addOption( - 'dir', - null, - InputOption::VALUE_REQUIRED, - sprintf( - 'Directory to copy file(s) valid options (%s)', - implode(',', $this->dirs) - ) - ) ->addOption( 'project', null, @@ -70,11 +61,17 @@ protected function configure() implode(',', $this->projects) ) ) + ->addOption( + 'global', + null, + InputOption::VALUE_NONE, + 'Copy configuration files to user home directory, instead of current working directory.' + ) ->addOption( 'override', null, InputOption::VALUE_NONE, - 'Override files on directory' + 'Copy files using override flag.' ); } @@ -83,20 +80,14 @@ protected function execute(InputInterface $input, OutputInterface $output) $application = $this->getApplication(); $config = $application->getConfig(); - $dir = $input->getOption('dir'); - - if (!$dir || !in_array($dir, $this->dirs)) { - throw new \Exception( - sprintf( - 'You must provide a valid dir value (%s)', - implode(',', $this->dirs) - ) - ); + $global = false; + if ($input->hasOption('global')) { + $global = $input->getOption('global'); } $project = $input->getOption('project'); - if ($project && !in_array($project, $this->projects)) { + if (!$project || !in_array($project, $this->projects)) { throw new \Exception( sprintf( 'You must provide a valid project value (%s)', @@ -110,12 +101,12 @@ protected function execute(InputInterface $input, OutputInterface $output) $override = $input->getOption('override'); } - if ($dir === 'current') { - $this->copyCurrentDirectory($output, $config, $override, $project); + if ($global) { + $this->copyHomeDirectory($output, $config, $override); } - if ($dir === 'home') { - $this->copyHomeDirectory($output, $config, $override); + if (!$global) { + $this->copyCurrentDirectory($output, $config, $override, $project); } }