Class: Abide::CLI::PuppetNewCommand
- Inherits:
-
AbideCommand
- Object
- CmdParse::Command
- AbideCommand
- Abide::CLI::PuppetNewCommand
- Defined in:
- lib/abide_dev_utils/cli/puppet.rb
Constant Summary collapse
- CMD_NAME =
'new'
- CMD_SHORT =
'Generates a new Puppet object from templates'
- CMD_LONG =
'Generates a new Puppet object (class, test, etc.) from templates stored in the module repo'
- CMD_TYPE_ARG =
'The type of object to generate. This value must be the name of a template (without .erb) file in <template dir>'
- CMD_NAME_ARG =
'The fully namespaced name of the new object'
Constants included from AbideDevUtils::Config
AbideDevUtils::Config::DEFAULT_PATH
Instance Method Summary collapse
- #execute(type, name) ⇒ Object
-
#initialize ⇒ PuppetNewCommand
constructor
A new instance of PuppetNewCommand.
Methods included from AbideDevUtils::Config
config_section, #config_section, fetch, #fetch, to_h, #to_h
Constructor Details
#initialize ⇒ PuppetNewCommand
Returns a new instance of PuppetNewCommand.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/abide_dev_utils/cli/puppet.rb', line 68 def initialize super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false) argument_desc(TYPE: CMD_TYPE_ARG, NAME: CMD_NAME_ARG) .on( '-t [DIR]', '--template-dir [DIR]', 'Path to the directory holding your ERB templates for custom objects. Defaults to "object_templates" in the root dir.' ) { |t| @data[:tmpl_dir] = t } .on( '-r [DIR]', '--root-dir [DIR]', 'Path to the root directory of the module. Defaults to the current working directory.' ) { |r| @data[:root_dir] = r } .on( '-A', '--absolute-template-dir', 'Use this flage if the template dir is an absolute path' ) { |a| @data[:absolute_template_dir] = a } .on( '-n [NAME]', '--template-name [NAME]', 'Allows you to specify a name for the template if it is different from the basename (last segment) of the object name.' ) .on( '-V [VARNAME=VALUE]', '--vars [VARNAME=VALUE]', 'Allows you to specify comma-separated variable names and values that will be converted into a hash that is available for you to use in your templates' ) { |v| @data[:vars] = v } .on( '-S [PATH]', '--spec-template [PATH]', 'Path to an ERB template to use for rspec test generation instead of the default' ) .on( '-f', '--force', 'Skips any prompts and executes the command' ) { |_| @data[:force] = true } end |
Instance Method Details
#execute(type, name) ⇒ Object
108 109 110 |
# File 'lib/abide_dev_utils/cli/puppet.rb', line 108 def execute(type, name) AbideDevUtils::Ppt.build_new_object(type, name, @data) end |