diff --git a/lib/vagrant/proto/gen/plugin/plugin_pb.rb b/lib/vagrant/proto/gen/plugin/plugin_pb.rb index 400e1453e..b30846c63 100644 --- a/lib/vagrant/proto/gen/plugin/plugin_pb.rb +++ b/lib/vagrant/proto/gen/plugin/plugin_pb.rb @@ -252,6 +252,18 @@ Google::Protobuf::DescriptorPool.generated_pool.build do end add_message "hashicorp.vagrant.sdk.Command" do end + add_message "hashicorp.vagrant.sdk.Command.Flag" do + optional :long_name, :string, 1 + optional :short_name, :string, 2 + optional :description, :string, 3 + optional :default_value, :string, 4 + optional :type, :enum, 5, "hashicorp.vagrant.sdk.Command.Flag.Type" + end + add_enum "hashicorp.vagrant.sdk.Command.Flag.Type" do + value :STRING, 0 + value :BOOL, 2 + value :INT, 3 + end add_message "hashicorp.vagrant.sdk.Command.HelpResp" do optional :help, :string, 1 end @@ -259,7 +271,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do optional :synopsis, :string, 1 end add_message "hashicorp.vagrant.sdk.Command.FlagsResp" do - optional :flags, :string, 1 + repeated :flags, :message, 1, "hashicorp.vagrant.sdk.Command.Flag" end add_message "hashicorp.vagrant.sdk.Communicator" do end @@ -381,6 +393,8 @@ module Hashicorp Provider::InstalledResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Provider.InstalledResp").msgclass Provider::ActionResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Provider.ActionResp").msgclass Command = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command").msgclass + Command::Flag = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command.Flag").msgclass + Command::Flag::Type = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command.Flag.Type").enummodule Command::HelpResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command.HelpResp").msgclass Command::SynopsisResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command.SynopsisResp").msgclass Command::FlagsResp = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("hashicorp.vagrant.sdk.Command.FlagsResp").msgclass diff --git a/plugins/commands/serve/service/command_service.rb b/plugins/commands/serve/service/command_service.rb index fd05b126e..47dc01413 100644 --- a/plugins/commands/serve/service/command_service.rb +++ b/plugins/commands/serve/service/command_service.rb @@ -12,9 +12,12 @@ module VagrantPlugins if !plugin raise "Failed to locate command plugin for: #{plugin_name}" end - # klass = plugin.call + $stashed_opts = nil + klass = Class.new(plugin.call) + klass.class_eval { def parse_options(opts); $stashed_opts = opts; nil; end }; + klass.new(['-h'], {}).execute Hashicorp::Vagrant::Sdk::Command::HelpResp.new( - help: "No help information configured" + help: $stashed_opts.help() ) end @@ -44,9 +47,17 @@ module VagrantPlugins if !plugin raise "Failed to locate command plugin for: #{plugin_name}" end - # klass = plugin.call + # klass = Class.new(plugin.call) + # klass.class_eval { + # } Hashicorp::Vagrant::Sdk::Command::FlagsResp.new( - flags: "not implemented" + flags: [ + Hashicorp::Vagrant::Sdk::Command::Flag.new( + long_name: "test", short_name: "t", + description: "does this even work?", default_value: "true", + type: Hashicorp::Vagrant::Sdk::Command::Flag::Type::BOOL + ) + ] ) end end