Class: Shell
- Inherits:
-
Gloo::Core::Obj
- Object
- Gloo::Core::Obj
- Shell
- Defined in:
- lib/shell.rb
Overview
- Author
-
Eric Crane (eric.crane@mac.com)
- Copyright
-
Copyright © 2026 Eric Crane. All rights reserved.
A CLI shell.
Constant Summary collapse
- KEYWORD =
'shell'.freeze
- KEYWORD_SHORT =
'shell'.freeze
- PROMPT =
'prompt'.freeze
- DEFAULT_ACTION =
'default_action'.freeze
- INCLUDE_QUIT =
'include_quit'.freeze
Class Method Summary collapse
-
.messages ⇒ Object
Get a list of message names that this object receives.
-
.short_typename ⇒ Object
The short name of the object type.
-
.typename ⇒ Object
The name of the object type.
Instance Method Summary collapse
-
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
-
#add_command(obj, command_data) ⇒ Object
Add a command to the shell.
-
#add_default_children ⇒ Object
Add children to this object.
-
#add_quit_command ⇒ Object
Quit the shell.
-
#get_runner ⇒ Object
Get the shell runner or initialize it if it doesn’t exist.
-
#include_quit? ⇒ Boolean
Get the value of the include_quit child object.
-
#msg_start ⇒ Object
Start the shell.
-
#msg_stop ⇒ Object
Stop the shell.
-
#prompt ⇒ Object
Get the value of the prompt child object.
-
#set_context(key, value) ⇒ Object
——————————————————————— Context ———————————————————————.
Class Method Details
.messages ⇒ Object
Get a list of message names that this object receives.
83 84 85 |
# File 'lib/shell.rb', line 83 def self. return super + [ 'start', 'stop' ] end |
.short_typename ⇒ Object
The short name of the object type.
25 26 27 |
# File 'lib/shell.rb', line 25 def self.short_typename return KEYWORD_SHORT end |
.typename ⇒ Object
The name of the object type.
18 19 20 |
# File 'lib/shell.rb', line 18 def self.typename return KEYWORD end |
Instance Method Details
#add_children_on_create? ⇒ Boolean
Does this object have children to add when an object is created in interactive mode? This does not apply during obj load, etc.
60 61 62 |
# File 'lib/shell.rb', line 60 def add_children_on_create? return true end |
#add_command(obj, command_data) ⇒ Object
Add a command to the shell.
116 117 118 119 |
# File 'lib/shell.rb', line 116 def add_command obj, command_data runner = get_runner runner.add_command_node( command_data ) end |
#add_default_children ⇒ Object
Add children to this object. This is used by containers to add children needed for default configurations.
69 70 71 72 73 |
# File 'lib/shell.rb', line 69 def add_default_children fac = @engine.factory fac.create_string PROMPT, '> ', self fac.create_script DEFAULT_ACTION, '', self end |
#add_quit_command ⇒ Object
Quit the shell.
138 139 140 141 142 143 144 145 146 |
# File 'lib/shell.rb', line 138 def add_quit_command return unless include_quit? @runner.add_command_node({ name: "quit", description: "Quit the application", method: "cmd_quit" }) end |
#get_runner ⇒ Object
Get the shell runner or initialize it if it doesn’t exist.
90 91 92 |
# File 'lib/shell.rb', line 90 def get_runner return @runner ||= ShellRunner.new( @engine, self ) end |
#include_quit? ⇒ Boolean
Get the value of the include_quit child object. Returns false if there is none.
44 45 46 47 48 |
# File 'lib/shell.rb', line 44 def include_quit? o = find_child INCLUDE_QUIT return o.value if o return false end |
#msg_start ⇒ Object
Start the shell.
97 98 99 100 101 102 103 104 |
# File 'lib/shell.rb', line 97 def msg_start runner = get_runner # add_test_commands add_quit_command runner.start end |
#msg_stop ⇒ Object
Stop the shell.
109 110 111 |
# File 'lib/shell.rb', line 109 def msg_stop @runner.stop if @runner end |
#prompt ⇒ Object
Get the value of the prompt child object. Returns nil if there is none.
33 34 35 36 37 38 |
# File 'lib/shell.rb', line 33 def prompt o = find_child PROMPT return '' unless o return o.value end |
#set_context(key, value) ⇒ Object
Context
126 127 128 |
# File 'lib/shell.rb', line 126 def set_context key, value @runner.set_context( key, value ) end |