Class: EYCli::Command::Console

Inherits:
Base
  • Object
show all
Includes:
EYCli
Defined in:
lib/ey_cli/commands/console.rb

Constant Summary

Constants included from EYCli

VERSION

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods included from EYCli

api, command_manager, term

Methods inherited from Base

#options_parser, #run

Instance Method Details

#apiObject



33
34
35
# File 'lib/ey_cli/commands/console.rb', line 33

def api
  EYCli.api
end

#helpObject



21
22
23
24
25
26
27
# File 'lib/ey_cli/commands/console.rb', line 21

def help
  <<-EOF

Usage: ey_cli console
Note: starts an interactive session.
EOF
end

#invokeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ey_cli/commands/console.rb', line 7

def invoke
  ARGV.clear
  IRB.setup(nil)
  @irb = IRB::Irb.new(nil)
  IRB.conf[:MAIN_CONTEXT] = @irb.context
  IRB.conf[:PROMPT][:EY_CLI] = IRB.conf[:PROMPT][:SIMPLE].dup
  IRB.conf[:PROMPT][:EY_CLI][:RETURN] = "%s\n"
  @irb.context.prompt_mode = :EY_CLI
  @irb.context.workspace = IRB::WorkSpace.new(binding)
  term.say('Welcome to ey_cli interactive!')

  catch(:IRB_EXIT) { @irb.eval_input }
end

#termObject



29
30
31
# File 'lib/ey_cli/commands/console.rb', line 29

def term
  EYCli.term
end