Method: Retrospec::Puppet::Generators::FunctionGenerator.run_cli
- Defined in:
- lib/retrospec/plugins/v1/plugin/generators/function_generator.rb
.run_cli(global_opts, args = ARGV) ⇒ Object
used to display subcommand options to the cli the global options are passed in for your usage trollop.rubyforge.org all options here are available in the config passed into config object returns the parameters
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/retrospec/plugins/v1/plugin/generators/function_generator.rb', line 51 def self.run_cli(global_opts, args=ARGV) func_types = %w(v3 v4 native) func_type = global_opts['plugins::puppet::default_function_version'] || 'v4' test_type = global_opts['plugins::puppet::default_function_test_type'] || 'rspec' sub_command_opts = Trollop.(args) do "Generates a new function with the given name.\n\n EOS\n opt :name, 'The name of the function you wish to create', :type => :string, :required => true, :short => '-n'\n opt :type, \"The version type of the function (\#{func_types.join(',')})\", :type => :string, :required => false, :short => '-t',\n :default => func_type\n opt :test_type, 'The type of test file to create (rspec, ruby)', :default => test_type, :type => :string, :short => '-u'\n opt :return_type, 'The return type of the function (rvalue, statement)', :type => :string, :required => false,\n :short => '-r', :default => 'rvalue'\n end\n\n unless func_types.include? sub_command_opts[:type].downcase\n puts \"Invalid type, must be one of \#{func_types.join(',')}\"\n Trollop.educate\n exit 1\n end\n unless sub_command_opts[:name]\n Trollop.educate\n exit 1\n end\n plugin_data = global_opts.merge(sub_command_opts)\n plugin_data\nend\n" |