Printing help due to invalid options should have error exit status

This commit is contained in:
Mitchell Hashimoto 2012-01-10 18:53:20 -08:00
parent 7eafb5fc1f
commit fe012e800f
3 changed files with 8 additions and 4 deletions

View File

@ -48,8 +48,7 @@ module Vagrant
opts.parse!(argv) opts.parse!(argv)
return argv return argv
rescue OptionParser::InvalidOption rescue OptionParser::InvalidOption
puts opts.help raise Errors::CLIInvalidOptions, :help => opts.help.chomp
return nil
end end
# Yields a VM for each target VM for the command. # Yields a VM for each target VM for the command.

View File

@ -128,9 +128,9 @@ module Vagrant
error_key(:failed, "vagrant.actions.box.verify") error_key(:failed, "vagrant.actions.box.verify")
end end
class CLIMissingEnvironment < VagrantError class CLIInvalidOptions < VagrantError
status_code(1) status_code(1)
error_key(:cli_missing_env) error_key(:cli_invalid_options)
end end
class ConfigValidationFailed < VagrantError class ConfigValidationFailed < VagrantError

View File

@ -26,6 +26,11 @@ en:
puppetd_not_detected: |- puppetd_not_detected: |-
The `puppetd` binary was not found on the VM is required for Puppet Server provisioning. The `puppetd` binary was not found on the VM is required for Puppet Server provisioning.
Please verify that Puppet is installed and that the binary is available on the PATH. Please verify that Puppet is installed and that the binary is available on the PATH.
cli_invalid_options: |-
An invalid option was specified. The help for this command
is available below.
%{help}
config_validation: |- config_validation: |-
There was a problem with the configuration of Vagrant. The error message(s) There was a problem with the configuration of Vagrant. The error message(s)
are printed below: are printed below: