Support arbitrary exit statuses for CLI commands that aren't exploding

This commit is contained in:
Mitchell Hashimoto 2012-03-23 11:07:35 -04:00
parent c1445a0130
commit 3338b6c134
18 changed files with 69 additions and 19 deletions

View File

@ -39,8 +39,8 @@ begin
logger.debug("Loading environment")
env.load!
# Execute the CLI interface
env.cli(ARGV)
# Execute the CLI interface, and exit with the proper error code
exit(env.cli(ARGV))
rescue Vagrant::Errors::VagrantError => e
logger.error("Vagrant experienced an error! Details:")
logger.error(e.inspect)

View File

@ -34,8 +34,10 @@ module Vagrant
return help if !command_class || !@sub_command
@logger.debug("Invoking command class: #{command_class} #{@sub_args.inspect}")
# Initialize and execute the command class.
command_class.new(@sub_args, @env).execute
# Initialize and execute the command class, returning the exit status.
result = command_class.new(@sub_args, @env).execute
result = 0 if !result.is_a?(Fixnum)
return result
end
# This prints out the help for the CLI.

View File

@ -28,6 +28,9 @@ module Vagrant
end
@env.boxes.add(argv[0], argv[1])
# Success, exit status 0
0
end
end
end

View File

@ -19,6 +19,9 @@ module Vagrant
return @env.ui.warn(I18n.t("vagrant.commands.box.no_installed_boxes"), :prefix => false)
end
boxes.each { |b| @env.ui.info(b.name, :prefix => false) }
# Success, exit status 0
0
end
end
end

View File

@ -18,6 +18,9 @@ module Vagrant
b = @env.boxes.find(argv[0])
raise Errors::BoxNotFound, :name => argv[0] if !b
b.destroy
# Success, exit status 0
0
end
end
end

View File

@ -18,6 +18,9 @@ module Vagrant
b = @env.boxes.find(argv[0])
raise Errors::BoxNotFound, :name => argv[0] if !b
b.repackage
# Success, exit status 0
0
end
end
end

View File

@ -55,6 +55,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -30,6 +30,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -31,6 +31,9 @@ module Vagrant
@env.ui.info(I18n.t("vagrant.commands.init.success"),
:prefix => false)
# Success, exit status 0
0
end
end
end

View File

@ -39,6 +39,9 @@ module Vagrant
else
package_target(argv[0], options)
end
# Success, exit status 0
0
end
protected

View File

@ -30,6 +30,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -29,6 +29,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -24,6 +24,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -53,6 +53,9 @@ module Vagrant
ssh_connect(vm, opts)
end
end
# Success, exit status 0
0
end
protected

View File

@ -42,6 +42,9 @@ module Vagrant
template = "commands/ssh_config/config"
safe_puts(Util::TemplateRenderer.render(template, variables))
end
# Success, exit status 0
0
end
end
end

View File

@ -27,6 +27,9 @@ module Vagrant
:states => results.join("\n"),
:message => I18n.t("vagrant.commands.status.#{state}")),
:prefix => false)
# Success, exit status 0
0
end
end
end

View File

@ -24,6 +24,9 @@ module Vagrant
vm.ui.info I18n.t("vagrant.commands.common.vm_not_created")
end
end
# Success, exit status 0
0
end
end
end

View File

@ -31,6 +31,9 @@ module Vagrant
vm.up(options)
end
end
# Success, exit status 0
0
end
end
end