Skip to content

Commit

Permalink
Merge pull request #19 from jmolivas/validate-init-global-project-opt…
Browse files Browse the repository at this point in the history
…ions

Validate init global project options
  • Loading branch information
jmolivas committed Aug 5, 2015
2 parents 87b2967 + 64435f0 commit d206afc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ $ ln -s /path/to/phpqa/bin/phpqa /usr/local/bin/phpqa
### Copy configuration file(s)
```
$ cd to/project/path
$ phpqa init --project=PROJECT --global --override
$ phpqa init --project=PROJECT --override
$ phpqa init --global --override
```
| Option | Description |
| -------- | ----------------------------- |
Expand All @@ -101,6 +102,7 @@ $ phpqa init --project=PROJECT --global --override
**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`.
- Options `project` and `global` can not used in combination.

### Analyze a project
```
Expand All @@ -117,8 +119,8 @@ $ phpqa analyze --project=PROJECT --git

**NOTES:**
- Option `git` does not accept a value must be set as `--git`.
- Options `files` and `git` can not used in combination.
- Option `project` could be omitted if a `phpqa.yml` or `phpqa.yml.dist` file is available at current working directory.
- Options `files` and `git` can not used in combination.

## Override configuration
This project was built to be fully customizable, you can enable/disable analyzers and modify arguments/options passed to analyzers by updating the `phpqa.yml` or `phpqa.yml.dist` file on your project root copied when running `init` command, or the files `~/.phpqa/php/config.yml`, `~/.phpqa/symfony/config.yml` or `~/.phpqa/drupal/config.yml` copied when running `init` command using `--global` option.
Expand Down
6 changes: 5 additions & 1 deletion src/Command/InitCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ protected function execute(InputInterface $input, OutputInterface $output)

$project = $input->getOption('project');

if (!$project || !in_array($project, $this->projects)) {
if ($global && $project) {
throw new \Exception('Options `project` and `global` can not used in combination.');
}

if (!$global && (!$project || !in_array($project, $this->projects))) {
throw new \Exception(
sprintf(
'You must provide a valid project value (%s)',
Expand Down

0 comments on commit d206afc

Please sign in to comment.