add more control on valid arguments for codecs in the generator command

Fixes #5419
This commit is contained in:
Pere Urbon-Bayes 2016-06-01 14:38:38 +02:00
parent ea4143602f
commit 0c1972a075

View file

@ -10,15 +10,12 @@ class LogStash::PluginManager::Generate < LogStash::PluginManager::Command
TYPES = [ "input", "filter", "output" ]
option "--type", "TYPE", "Type of the plugin {input, filter, output}s" do |arg|
raise(ArgumentError, "should be one of: input, output or filter") unless TYPES.include?(arg)
arg
end
option "--type", "TYPE", "Type of the plugin {input, filter, output}s", :required => true
option "--name", "PLUGIN", "Name of the new plugin", :required => true
option "--path", "PATH", "Location where the plugin skeleton will be created", :default => Dir.pwd
def execute
validate_params
source = File.join(File.dirname(__FILE__), "templates", "#{type}-plugin")
@target_path = File.join(path, full_plugin_name)
FileUtils.mkdir(@target_path)
@ -35,6 +32,10 @@ class LogStash::PluginManager::Generate < LogStash::PluginManager::Command
private
def validate_params
raise(ArgumentError, "should be one of: input, output or filter") unless TYPES.include?(type)
end
def create_scaffold(source, target)
transform_r(source, target)
end