yiisoft/yii2 — pull request #5611 by motin (2014-10-16 23:55:01+00:00)
Title: Fixes #5610 - Gii with --generate=1 is not available in cli and does not overwrite existing files as is claimed in the phpdoc

Fixes #5610 - Gii with --generate=1 is not available in cli and does not overwrite existing files as is claimed in the phpdoc

Testcase:
1. Set-up the basic app as instruction on https://github.com/yiisoft/yii2/blob/master/docs/internals/getting-started.md#getting-started-with-yii2-development
2. Add an empty database and adjust db credentials
3. Run the following commands:
```
$ ./yii migrate
Yii Migration Tool (based on Yii v2.0.1-dev)

Creating migration history table "migration"...done.
No new migration found. Your system is up-to-date.

$ ./yii gii/model --tableName=*
Running 'Model Generator'...

The following files will be generated:
[new] models/Migration.php

Ready to generate the selected files? (yes|no) [yes]:

Files were generated successfully!
Generating code using template "/Users/motin/Dev/Projects/Gapminder/gs-dev/cms/yiiapps/internal-db-yii2-frontend/vendor/yiisoft/yii2-pr-base/extensions/gii/generators/model/default"...
generated models/Migration.php
done!

$ ./yii gii/model --tableName=*
Running 'Model Generator'...

The following files will be generated:
[unchanged] models/Migration.php

No files were chosen to be generated.

$ echo "a-change" >> models/Migration.php

$ ./yii gii/model --tableName=*
Running 'Model Generator'...

The following files will be generated:
[changed] models/Migration.php
Do you want to overwrite this file? [y,n,ya,na,?]: ^C

$ ./yii gii/model --tableName=* --interactive=0
Running 'Model Generator'...

The following files will be generated:
[changed] models/Migration.php

No files were chosen to be generated.

```

Without any of these commits, the following happens:
```
$ ./yii gii/model --tableName=* --interactive=0 --generate=1
Error: Unknown option: --generate
```

With [the first commit](https://github.com/motin/yii2/commit/80f4e46f5579df3aa94e67030f304d63fd31e10d) but without [the second commit](https://github.com/motin/yii2/commit/c7c855fc3321b2e9cdbd3d547b9bb1008748b756), the following happens:
```
$ ./yii gii/model --tableName=* --interactive=0 --generate=1
Running 'Model Generator'...

The following files will be generated:
[changed] models/Migration.php

No files were chosen to be generated.
```

With the second commit, the desired behavior is achieved:
```

$ ./yii gii/model --tableName=* --interactive=0 --generate=1
Running 'Model Generator'...

The following files will be generated:
[changed] models/Migration.php

Files were generated successfully!
Generating code using template "/Users/motin/Dev/Projects/Gapminder/gs-dev/cms/yiiapps/internal-db-yii2-frontend/vendor/yiisoft/yii2-pr-base/extensions/gii/generators/model/default"...
overwrote models/Migration.php
done!
```