From 0c1972a075c85462654f54ca1e15a8800058ae75 Mon Sep 17 00:00:00 2001 From: Pere Urbon-Bayes Date: Wed, 1 Jun 2016 14:38:38 +0200 Subject: [PATCH] add more control on valid arguments for codecs in the generator command Fixes #5419 --- lib/pluginmanager/generate.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/pluginmanager/generate.rb b/lib/pluginmanager/generate.rb index ccd0009ce..7ae113148 100644 --- a/lib/pluginmanager/generate.rb +++ b/lib/pluginmanager/generate.rb @@ -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