Module: Pvectl::Commands::IrreversibleCommand
- Included in:
- DeleteCommand, TemplateCommand
- Defined in:
- lib/pvectl/commands/irreversible_command.rb
Overview
Shared functionality for irreversible batch commands (delete, template).
Provides the generic flow: resolve resources → confirm → execute → format results. Submodules override hooks to customize behavior per operation.
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
-
.included(base) ⇒ Object
Hook called when module is included.
Instance Method Summary collapse
-
#execute ⇒ Integer
Executes the command.
-
#initialize(resource_type, resource_ids, options, global_options) ⇒ Object
Initializes an irreversible command.
Class Method Details
.included(base) ⇒ Object
Hook called when module is included.
37 38 39 |
# File 'lib/pvectl/commands/irreversible_command.rb', line 37 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#execute ⇒ Integer
Executes the command.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/pvectl/commands/irreversible_command.rb', line 57 def execute return usage_error("Resource type required (#{supported_types.join(', ')})") unless @resource_type return usage_error("Unsupported resource: #{@resource_type}") unless supported_resource? if @resource_ids.empty? && !@options[:all] && selector_strings.empty? return usage_error("VMID, --all, or -l selector required") end perform_operation end |
#initialize(resource_type, resource_ids, options, global_options) ⇒ Object
Initializes an irreversible command.
47 48 49 50 51 52 |
# File 'lib/pvectl/commands/irreversible_command.rb', line 47 def initialize(resource_type, resource_ids, , ) @resource_type = resource_type @resource_ids = Array(resource_ids).compact @options = @global_options = end |