puppetlabs/puppet — pull request #2721 by peterhuene (2014-06-02 21:06:12+00:00)
Title: (PUP-2622) Use non-zero exit codes for unknown subcommands.

Previously, if users execute 'puppet foo', an error message is displayed
about unknown subcommand 'foo', but puppet still exits with a zero exit
code indicating success.

Additionally, if users execute 'puppet --option ',
puppet silently ignores the option, prints a message, and exits with a
zero exit code. As a result, a user accidentally transposed a valid
option for a subcommand with the subcommand itself in an automated context
and puppet did not report a failure.

This commit fixes both conditions by exiting with 1 from the nil and unknown
subcommands where appropriate. It also prints error messages using the same
colorized output we use for usual puppet errors.