Class: Roast::Workflow::InputStep

Inherits:
BaseStep
  • Object
show all
Defined in:
lib/roast/workflow/input_step.rb

Instance Attribute Summary collapse

Attributes inherited from BaseStep

#available_tools, #coerce_to, #context_path, #json, #model, #name, #params, #print_response, #resource, #workflow

Instance Method Summary collapse

Constructor Details

#initialize(workflow, config:, **kwargs) ⇒ InputStep

Returns a new instance of InputStep.



10
11
12
13
# File 'lib/roast/workflow/input_step.rb', line 10

def initialize(workflow, config:, **kwargs)
  super(workflow, **kwargs)
  parse_config(config)
end

Instance Attribute Details

#defaultObject (readonly)

Returns the value of attribute default.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def default
  @default
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def options
  @options
end

#prompt_textObject (readonly)

Returns the value of attribute prompt_text.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def prompt_text
  @prompt_text
end

#requiredObject (readonly)

Returns the value of attribute required.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def required
  @required
end

#step_nameObject (readonly)

Returns the value of attribute step_name.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def step_name
  @step_name
end

#timeoutObject (readonly)

Returns the value of attribute timeout.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def timeout
  @timeout
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/roast/workflow/input_step.rb', line 8

def type
  @type
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/roast/workflow/input_step.rb', line 15

def call
  # Get user input based on the configured type
  result = case type
  when "boolean"
    prompt_boolean
  when "choice"
    prompt_choice
  when "password"
    prompt_password
  else
    prompt_text_input
  end

  # Store the result in workflow state if a name was provided
  store_in_state(result) if step_name

  result
rescue Interrupt
  raise Roast::Errors::ExitEarly
rescue Timeout::Error
  handle_timeout
end