composer/composer — pull request #3096 by weaverryan (2014-07-05 19:14:02+00:00)
Title: Automatically select latest version (by stability) on init/require

Hi guys!

This follows Jordi's suggestion on #2492 by automatically choosing the latest version when using the require (or init) command for dependencies:

**Previously**: If you omitted the version of a library, it prompted you to enter a version.

**New Behavior**: If you omit the version, it automatically selects the latest version that is consistent
with your minimum-stability flag.

It also prefixes the `~` on real versions (but not for `dev` versions like `dev-master`).

Some of the code is a bit of a mess, like the logic for finding the latest version is now repeated in `CreateProjectCommand` and my handling of trying to get the correct version to actually put into `composer.json` is messy (you can't use `$package->getVersion()`, as it returns things like `2.1.2.0`, when the release is really `2.1.2`, and what we want is `~2.1.2`). Suggestions on cleanup for that part are warmly welcomed.

Thanks!