Module: Pvectl::Commands::CreateResourceCommand Abstract

Included in:
CreateContainer, CreateVm
Defined in:
lib/pvectl/commands/create_resource_command.rb

Overview

This module is abstract.

Include this module and implement template methods.

Shared functionality for resource creation commands.

Template method pattern: provides common create workflow (interactive detection, confirmation, dry-run, config loading) while specialization classes define resource-specific hooks.

Examples:

Specialization

class CreateVm
  include CreateResourceCommand
  private
  def resource_label = "VM"
  def resource_id_label = "VMID"
  # ...
end

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

Hook called when module is included.

Parameters:

  • base (Class)

    the class including this module



39
40
41
# File 'lib/pvectl/commands/create_resource_command.rb', line 39

def self.included(base)
  base.extend(ClassMethods)
end

Instance Method Details

#executeInteger

Executes the create command.

Returns:

  • (Integer)

    exit code



57
58
59
60
61
62
63
# File 'lib/pvectl/commands/create_resource_command.rb', line 57

def execute
  if interactive_mode?
    perform_interactive
  else
    perform_create
  end
end

#initialize(args, options, global_options) ⇒ Object

Initializes a create command.

Parameters:

  • args (Array<String>)

    command arguments

  • options (Hash)

    command options

  • global_options (Hash)

    global CLI options



48
49
50
51
52
# File 'lib/pvectl/commands/create_resource_command.rb', line 48

def initialize(args, options, global_options)
  @args = args
  @options = options
  @global_options = global_options
end