diff --git a/plugins/commands/validate/command.rb b/plugins/commands/validate/command.rb new file mode 100644 index 000000000..9d6ad7bb2 --- /dev/null +++ b/plugins/commands/validate/command.rb @@ -0,0 +1,31 @@ +require 'optparse' + +module VagrantPlugins + module CommandValidate + class Command < Vagrant.plugin("2", :command) + def self.synopsis + "validates the Vagrantfile" + end + + def execute + opts = OptionParser.new do |o| + o.banner = "Usage: vagrant validate" + end + + # Parse the options + argv = parse_options(opts) + return if !argv + + # Validate the configuration + @env.machine(@env.machine_names.first, @env.default_provider).action_raw( + :config_validate, + Vagrant::Action::Builtin::ConfigValidate) + + @env.ui.info(I18n.t("vagrant.commands.validate.success")) + + # Success, exit status 0 + 0 + end + end + end +end diff --git a/plugins/commands/validate/plugin.rb b/plugins/commands/validate/plugin.rb new file mode 100644 index 000000000..31a558b77 --- /dev/null +++ b/plugins/commands/validate/plugin.rb @@ -0,0 +1,17 @@ +require "vagrant" + +module VagrantPlugins + module CommandValidate + class Plugin < Vagrant.plugin("2") + name "validate command" + description <<-DESC + The `validate` command validates the Vagrantfile. + DESC + + command("validate") do + require File.expand_path("../command", __FILE__) + Command + end + end + end +end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 1dc166863..e6a034dce 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1726,6 +1726,9 @@ en: up: upping: |- Bringing machine '%{name}' up with '%{provider}' provider... + validate: + success: |- + Vagrantfile validated successfully. #------------------------------------------------------------------------------- # Translations for Vagrant middleware actions