Class: Shelley::NonInteractiveShell

Inherits:
Object
  • Object
show all
Defined in:
lib/shelley/shells.rb

Overview

A non-interactive shell. Executes given commands sequentially

Instance Method Summary collapse

Constructor Details

#initialize(command_registry, commands) ⇒ NonInteractiveShell

Returns a new instance of NonInteractiveShell.



45
46
47
48
# File 'lib/shelley/shells.rb', line 45

def initialize(command_registry, commands)
  @command_registry = command_registry
  @commands = commands
end

Instance Method Details

#startObject

Starts the shell



51
52
53
54
55
56
57
58
59
60
# File 'lib/shelley/shells.rb', line 51

def start
  @commands.each do |command|
    begin
      puts "> #{command}"
      @command_registry.execute_command(command)
    rescue StandardError => msg
      puts msg
    end
  end
end