vaguerent/plugins/commands/serve/service/command_service.rb
2022-04-25 12:23:52 -05:00

56 lines
1.7 KiB
Ruby

module VagrantPlugins
module CommandServe
module Service
class CommandService < Hashicorp::Vagrant::Sdk::CommandService::Service
def help_spec(*args)
Hashicorp::Vagrant::Sdk::FuncSpec.new
end
def help(*args)
plugin_name = args.last.metadata["plugin_name"]
plugin = Vagrant::Plugin::V2::Plugin.manager.commands[plugin_name.to_sym].to_a.first
if !plugin
raise "Failed to locate command plugin for: #{plugin_name}"
end
# klass = plugin.call
Hashicorp::Vagrant::Sdk::Command::HelpResp.new(
help: "No help information configured"
)
end
def synopsis_spec(*args)
return Hashicorp::Vagrant::Sdk::FuncSpec.new
end
def synopsis(*args)
plugin_name = args.last.metadata["plugin_name"]
plugin = Vagrant::Plugin::V2::Plugin.manager.commands[plugin_name.to_sym].to_a.first
if !plugin
raise "Failed to locate command plugin for: #{plugin_name}"
end
klass = plugin.call
Hashicorp::Vagrant::Sdk::Command::SynopsisResp.new(
synopsis: klass.synopsis
)
end
def flags_spec(*args)
Hashicorp::Vagrant::Sdk::FuncSpec.new
end
def flags(*args)
plugin_name = args.last.metadata["plugin_name"]
plugin = Vagrant::Plugin::V2::Plugin.manager.commands[plugin_name.to_sym].to_a.first
if !plugin
raise "Failed to locate command plugin for: #{plugin_name}"
end
# klass = plugin.call
Hashicorp::Vagrant::Sdk::Command::FlagsResp.new(
flags: "not implemented"
)
end
end
end
end
end