Class: Vop::Shell

Inherits:
Object
  • Object
show all
Defined in:
lib/vop/shell.rb

Constant Summary collapse

USAGE =
<<DOCOPT
virtualop

Usage:
  vop [options]

Options:
  -h --help       show this help screen
  -v --verbose    enable debug output
  -e --execute=<command>  to run a command directly

DOCOPT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vop = nil, options = {}) ⇒ Shell

Returns a new instance of Shell.



28
29
30
31
32
33
34
# File 'lib/vop/shell.rb', line 28

def initialize(vop = nil, options = {})
  @op = vop || Vop.new
  @options = options

  backend = VopShellBackend.new(@op, :color_prompt => true)
  @base_shell = BaseShell.new(backend)
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



26
27
28
# File 'lib/vop/shell.rb', line 26

def op
  @op
end

#optionsObject (readonly)

Returns the value of attribute options.



25
26
27
# File 'lib/vop/shell.rb', line 25

def options
  @options
end

Class Method Details

.setupObject



44
45
46
47
48
49
# File 'lib/vop/shell.rb', line 44

def self.setup()
  options = Docopt::docopt(USAGE, {:help => true})

  vop = Vop.new(options)
  return Shell.new(vop, options)
end

Instance Method Details

#execute(string) ⇒ Object



36
37
38
# File 'lib/vop/shell.rb', line 36

def execute(string)
  @base_shell.backend.process_input(string)
end

#run_cliObject



40
41
42
# File 'lib/vop/shell.rb', line 40

def run_cli
  @base_shell.run
end