Class: RGovData::Shell
- Inherits:
-
Object
- Object
- RGovData::Shell
- Includes:
- CommonConfig
- Defined in:
- lib/rgovdata/shell/shell.rb
Constant Summary collapse
- OPTIONS =
command line options definition
%w(help verbose command=@s)
Instance Attribute Summary collapse
-
#discovery_path ⇒ Object
Returns the value of attribute discovery_path.
-
#options ⇒ Object
Returns the value of attribute options.
-
#prompt ⇒ Object
writeonly
Sets the attribute prompt.
Class Method Summary collapse
-
.usage ⇒ Object
Usage message.
Instance Method Summary collapse
-
#initialize(options) ⇒ Shell
constructor
new
. -
#run ⇒ Object
run the basic REPL.
Methods included from CommonConfig
Constructor Details
#initialize(options) ⇒ Shell
new
40 41 42 43 44 |
# File 'lib/rgovdata/shell/shell.rb', line 40 def initialize() require_config_file @options = (||{}).each{|k,v| {k => v} } @discovery_path = [config.default_realm].compact end |
Instance Attribute Details
#discovery_path ⇒ Object
Returns the value of attribute discovery_path.
4 5 6 |
# File 'lib/rgovdata/shell/shell.rb', line 4 def discovery_path @discovery_path end |
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/rgovdata/shell/shell.rb', line 3 def @options end |
#prompt=(value) ⇒ Object
Sets the attribute prompt
3 4 5 |
# File 'lib/rgovdata/shell/shell.rb', line 3 def prompt=(value) @prompt = value end |
Class Method Details
.usage ⇒ Object
Usage message
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rgovdata/shell/shell.rb', line 9 def self.usage puts <<-EOS rgovdata client v#{RGovData::Version::STRING} =================================== Usage: rgd [options] Command Options -c | --command immediately executes the command provided The following commands are supported in the rgovdata shell. They can also be passed on the command line: rgd -c command == Core Commands == help exit show status == Discovery Commands == ls cd info EOS end |
Instance Method Details
#run ⇒ Object
run the basic REPL
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rgovdata/shell/shell.rb', line 47 def run if [:command].present? evaluate [:command].join(' ') return end welcome repl = lambda do |prompt| print prompt evaluate( STDIN.gets.chomp! ) end loop { break unless repl[prompt] } end |