Class: Abide::CLI::PuppetRenameCommand

Inherits:
AbideCommand
  • Object
show all
Defined in:
lib/abide_dev_utils/cli/puppet.rb

Constant Summary collapse

CMD_NAME =
'rename'
CMD_SHORT =
'Renames a Puppet class'
CMD_LONG =
'Renames a Puppet class. It does this by renaming the file and also the class name in the file. This command can also move class files based on the new class name.'
CMD_FROM_ARG =
'The current full class name'
CMD_TO_ARG =
'The new full class name'

Constants included from AbideDevUtils::Config

AbideDevUtils::Config::DEFAULT_PATH

Instance Method Summary collapse

Methods inherited from AbideCommand

#deprecated?, #on_after_add

Methods included from AbideDevUtils::Config

config_section, #config_section, fetch, #fetch, #to_h, to_h

Constructor Details

#initializePuppetRenameCommand

Returns a new instance of PuppetRenameCommand.



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/abide_dev_utils/cli/puppet.rb', line 119

def initialize
  super(CMD_NAME, CMD_SHORT, CMD_LONG, takes_commands: false)
  argument_desc(FROM: CMD_FROM_ARG, TO: CMD_TO_ARG)
  options.on(
    '-d',
    '--declaration-only',
    'Will not rename the class file, only the class declaration in the file'
  ) { @data[:declaration_only] = true }
  options.on(
    '-t',
    '--declaration-in-to-file',
    'Use the path derived from the TO class name as the existing file path when renaming class declaration'
  ) { @data[:declaration_in_to_file] = true }
  options.on(
    '-f',
    '--force',
    'Forces file move operations'
  ) { @data[:force] = true }
  options.on(
    '-v',
    '--verbose',
    'Sets verbose mode on file operations'
  ) { @data[:verbose] = true }
end

Instance Method Details

#execute(from, to) ⇒ Object



144
145
146
# File 'lib/abide_dev_utils/cli/puppet.rb', line 144

def execute(from, to)
  AbideDevUtils::Ppt.rename_puppet_class(from, to, **@data)
end