Class: Pvectl::Wizards::CreateContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/pvectl/wizards/create_container.rb

Overview

Interactive wizard for creating an LXC container step by step.

Uses TTY::Prompt (when available) or a fallback prompt to guide the user through container configuration. Returns a normalized params hash compatible with Services::CreateContainer, or nil if the user cancels.

Examples:

Running the wizard

wizard = CreateContainer.new(options, global_options)
params = wizard.run
#=> { hostname: "web-ct", node: "pve1", ... } or nil

Instance Method Summary collapse

Constructor Details

#initialize(options, global_options, prompt: nil) ⇒ CreateContainer

Creates a new CreateContainer wizard.

Parameters:

  • options (Hash)

    command options (may contain pre-filled values)

  • global_options (Hash)

    global CLI options

  • prompt (Object) (defaults to: nil)

    prompt instance (injectable for testing)



22
23
24
25
26
# File 'lib/pvectl/wizards/create_container.rb', line 22

def initialize(options, global_options, prompt: nil)
  @options = options
  @global_options = global_options
  @prompt = prompt || create_default_prompt
end

Instance Method Details

#runHash?

Runs the wizard and returns params or nil if cancelled.

Returns:

  • (Hash, nil)

    creation params or nil if user cancels



31
32
33
# File 'lib/pvectl/wizards/create_container.rb', line 31

def run
  collect_params
end