Skip to content

Commit d206afc

Browse files
committed
Merge pull request #19 from jmolivas/validate-init-global-project-options
Validate init global project options
2 parents 87b2967 + 64435f0 commit d206afc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ $ ln -s /path/to/phpqa/bin/phpqa /usr/local/bin/phpqa
9090
### Copy configuration file(s)
9191
```
9292
$ cd to/project/path
93-
$ phpqa init --project=PROJECT --global --override
93+
$ phpqa init --project=PROJECT --override
94+
$ phpqa init --global --override
9495
```
9596
| Option | Description |
9697
| -------- | ----------------------------- |
@@ -101,6 +102,7 @@ $ phpqa init --project=PROJECT --global --override
101102
**NOTES:**
102103
- Option `global` does not accept a value must be set as `--global`.
103104
- Option `override` does not accept a value must be set as `--override`.
105+
- Options `project` and `global` can not used in combination.
104106

105107
### Analyze a project
106108
```
@@ -117,8 +119,8 @@ $ phpqa analyze --project=PROJECT --git
117119

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

123125
## Override configuration
124126
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.

src/Command/InitCommand.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ protected function execute(InputInterface $input, OutputInterface $output)
8787

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

90-
if (!$project || !in_array($project, $this->projects)) {
90+
if ($global && $project) {
91+
throw new \Exception('Options `project` and `global` can not used in combination.');
92+
}
93+
94+
if (!$global && (!$project || !in_array($project, $this->projects))) {
9195
throw new \Exception(
9296
sprintf(
9397
'You must provide a valid project value (%s)',

0 commit comments

Comments
 (0)