gloo 6.0.1 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CLAUDE.md +9 -3
  3. data/README.md +39 -7
  4. data/docs/application.md +184 -0
  5. data/docs/getting_started.md +110 -0
  6. data/docs/iterators.md +294 -0
  7. data/docs/language_objects.md +190 -0
  8. data/docs/language_scripting.md +62 -0
  9. data/docs/language_syntax.md +334 -0
  10. data/docs/objects.md +77 -0
  11. data/docs/operators.md +62 -0
  12. data/docs/plugins.md +376 -0
  13. data/docs/verbs.md +64 -0
  14. data/docs/web_app.md +211 -0
  15. data/gloo.gemspec +3 -1
  16. data/lib/VERSION +1 -1
  17. data/lib/VERSION_NOTES +16 -0
  18. data/lib/gloo/app/engine.rb +17 -2
  19. data/lib/gloo/app/log.rb +5 -4
  20. data/lib/gloo/app/platform.rb +34 -2
  21. data/lib/gloo/app/prompt.rb +2 -1
  22. data/lib/gloo/app/settings.rb +25 -15
  23. data/lib/gloo/app/table.rb +7 -3
  24. data/lib/gloo/app/theme.rb +144 -0
  25. data/lib/gloo/core/gloo_system.rb +52 -1
  26. data/lib/gloo/core/invoker.rb +102 -0
  27. data/lib/gloo/core/parser.rb +48 -7
  28. data/lib/gloo/core/tokens.rb +81 -1
  29. data/lib/gloo/docs/doc_data.rb +160 -0
  30. data/lib/gloo/docs/help_shell.rb +332 -0
  31. data/lib/gloo/docs/markdown_renderer.rb +39 -0
  32. data/lib/gloo/expr/call.rb +54 -0
  33. data/lib/gloo/expr/expression.rb +3 -0
  34. data/lib/gloo/objs/basic/alias.rb +53 -0
  35. data/lib/gloo/objs/basic/boolean.rb +30 -0
  36. data/lib/gloo/objs/basic/container.rb +38 -0
  37. data/lib/gloo/objs/basic/decimal.rb +30 -0
  38. data/lib/gloo/objs/basic/integer.rb +58 -0
  39. data/lib/gloo/objs/basic/script.rb +31 -0
  40. data/lib/gloo/objs/basic/string.rb +31 -4
  41. data/lib/gloo/objs/basic/string_msgs.rb +212 -2
  42. data/lib/gloo/objs/basic/text.rb +30 -4
  43. data/lib/gloo/objs/basic/untyped.rb +21 -0
  44. data/lib/gloo/objs/ctrl/each.rb +63 -1
  45. data/lib/gloo/objs/ctrl/function.rb +86 -4
  46. data/lib/gloo/objs/ctrl/repeat.rb +41 -0
  47. data/lib/gloo/objs/dt/date.rb +43 -0
  48. data/lib/gloo/objs/dt/datetime.rb +50 -0
  49. data/lib/gloo/objs/dt/time.rb +43 -0
  50. data/lib/gloo/objs/str_utils/cipher.rb +59 -0
  51. data/lib/gloo/objs/str_utils/outline.rb +65 -1
  52. data/lib/gloo/objs/str_utils/password.rb +56 -0
  53. data/lib/gloo/objs/system/erb.rb +39 -0
  54. data/lib/gloo/objs/system/file_handle.rb +56 -0
  55. data/lib/gloo/objs/system/system.rb +29 -0
  56. data/lib/gloo/objs/web/http_get.rb +35 -0
  57. data/lib/gloo/objs/web/http_post.rb +33 -0
  58. data/lib/gloo/objs/web/json.rb +40 -0
  59. data/lib/gloo/objs/web/uri.rb +40 -0
  60. data/lib/gloo/shell/command_node.rb +39 -0
  61. data/lib/gloo/shell/context.rb +93 -0
  62. data/lib/gloo/shell/runner.rb +315 -0
  63. data/lib/gloo/verbs/break.rb +32 -0
  64. data/lib/gloo/verbs/check.rb +49 -0
  65. data/lib/gloo/verbs/cls.rb +18 -0
  66. data/lib/gloo/verbs/context.rb +47 -0
  67. data/lib/gloo/verbs/create.rb +42 -0
  68. data/lib/gloo/verbs/eval.rb +27 -0
  69. data/lib/gloo/verbs/execute.rb +27 -0
  70. data/lib/gloo/verbs/exists.rb +54 -2
  71. data/lib/gloo/verbs/files.rb +22 -0
  72. data/lib/gloo/verbs/help.rb +46 -178
  73. data/lib/gloo/verbs/if.rb +52 -0
  74. data/lib/gloo/verbs/invoke.rb +88 -33
  75. data/lib/gloo/verbs/list.rb +37 -4
  76. data/lib/gloo/verbs/load.rb +55 -2
  77. data/lib/gloo/verbs/log.rb +44 -0
  78. data/lib/gloo/verbs/move.rb +36 -1
  79. data/lib/gloo/verbs/put.rb +35 -0
  80. data/lib/gloo/verbs/quit.rb +19 -0
  81. data/lib/gloo/verbs/redirect.rb +52 -2
  82. data/lib/gloo/verbs/reload.rb +27 -0
  83. data/lib/gloo/verbs/run.rb +39 -0
  84. data/lib/gloo/verbs/save.rb +26 -0
  85. data/lib/gloo/verbs/show.rb +54 -0
  86. data/lib/gloo/verbs/tell.rb +32 -0
  87. data/lib/gloo/verbs/throw.rb +29 -0
  88. data/lib/gloo/verbs/unless.rb +50 -0
  89. data/lib/gloo/verbs/unload.rb +23 -0
  90. data/lib/gloo/verbs/version.rb +37 -3
  91. data/lib/gloo/verbs/wait.rb +26 -0
  92. data/test.gloo/objs/string.test.gloo +54 -0
  93. data/test.gloo/verbs/invoke.test.gloo +73 -0
  94. metadata +26 -10
  95. data/.DS_Store +0 -0
  96. data/.travis.yml +0 -5
@@ -43,6 +43,28 @@ module Gloo
43
43
 
44
44
  private
45
45
 
46
+ # ---------------------------------------------------------------------
47
+ # Verb Documentation
48
+ # ---------------------------------------------------------------------
49
+
50
+ #
51
+ # Get the verb's documentation data.
52
+ #
53
+ def self.doc_data
54
+ {
55
+ :name => KEYWORD,
56
+ :shortcut => KEYWORD_SHORT,
57
+ :description => 'Show a list of all loaded files and their ' \
58
+ 'associated objects.',
59
+ :syntax => [ 'files' ],
60
+ :result => 'The list of files and associated objects is shown ' \
61
+ 'in output. It is set to the number of files that have been loaded.',
62
+ :examples => <<~EXAMPLES.strip
63
+ > files
64
+ EXAMPLES
65
+ }
66
+ end
67
+
46
68
  end
47
69
  end
48
70
  end
@@ -10,41 +10,18 @@ module Gloo
10
10
 
11
11
  KEYWORD = 'help'.freeze
12
12
  KEYWORD_SHORT = '?'.freeze
13
- DEFAULT_HELP = 'default_help'.freeze
14
- HELP_NOT_FOUND_ERR = 'Help command could not be found:'.freeze
15
13
 
16
- DISPATCH = {
17
- s: 'show_settings',
18
- settings: 'show_settings',
19
- verb: 'show_verbs',
20
- verbs: 'show_verbs',
21
- v: 'show_verbs',
22
- o: 'show_objs',
23
- obj: 'show_objs',
24
- object: 'show_objs',
25
- objects: 'show_objs',
26
- e: 'show_ext',
27
- ext: 'show_ext',
28
- l: 'show_lib',
29
- lib: 'show_lib',
30
- library: 'show_lib',
31
- libraries: 'show_lib',
32
- extension: 'show_ext',
33
- extensions: 'show_ext'
34
- }.freeze
14
+ BANNER = "Entering the gloo help shell. Type 'quit' to exit.\n" \
15
+ "Try: verbs, objects, settings, theme, extensions, libraries, docs, " \
16
+ "verb {name}, object {name}, doc {name}, library {name}, extension {name}\n".freeze
35
17
 
36
18
  #
37
19
  # Run the verb.
20
+ # Takes no arguments - always enters the interactive help shell.
38
21
  #
39
22
  def run
40
- opts = @tokens.second if @tokens
41
- opts = opts.strip.downcase if opts
42
-
43
- if opts
44
- dispatch opts
45
- else
46
- show_default_help
47
- end
23
+ @engine.log.show BANNER
24
+ build_shell.start
48
25
  end
49
26
 
50
27
  #
@@ -62,166 +39,57 @@ module Gloo
62
39
  end
63
40
 
64
41
  # ---------------------------------------------------------------------
65
- # Private functions
42
+ # Verb Documentation
66
43
  # ---------------------------------------------------------------------
67
44
 
68
- private
69
-
70
- #
71
- # Write output to it and show it unless we are in
72
- # silent mode.
73
- #
74
- def show_output( out )
75
- @engine.heap.it.set_to out
76
- puts out unless @engine.args.quiet?
77
- end
78
-
79
- #
80
- # Show application settings.
81
- #
82
- def show_settings
83
- @engine.settings.show
84
- end
85
-
86
- #
87
- # Show default help.
88
- # No parameters were given.
89
- #
90
- def show_default_help
91
- data = "\n"
92
- data << " Help Options:\n"
93
- data << " ? objects (obj, o) \n"
94
- data << " ? verbs (v) \n"
95
- data << " ? ext (e) \n"
96
- data << " ? lib (l) \n"
97
- data << " ? settings (s) \n"
98
- data << "\n For detailed documentation use the gloo website. \n"
99
- data << "\n https://gloo.ecrane.us/doc/. \n\n"
100
- @engine.log.show data
101
- end
102
-
103
- #
104
- # Dispatch the help to the right place.
105
- #
106
- def dispatch( opts )
107
- @engine.log.debug 'looking for help topic'
108
- cmd = DISPATCH[ opts.to_sym ]
109
- if cmd
110
- @engine.log.debug 'found help command'
111
- send cmd
112
- else
113
- report_help_error opts
114
- end
115
- end
116
-
117
- #
118
- # Report an error with the inline help.
119
- #
120
- def report_help_error( opts )
121
- @engine.err "#{HELP_NOT_FOUND_ERR} '#{opts}'"
122
- end
123
-
124
- #
125
- # List the verbs
126
- #
127
- def show_verbs
128
- data = "\n"
129
- data << " Verbs (shortcut, name)\n".blue
130
- data << "#{get_verbs}\n\n"
131
- @engine.log.show data
132
- end
133
-
134
- #
135
- # List the object types
136
45
  #
137
- def show_objs
138
- data = "\n"
139
- data << " Objects \n".blue
140
- data << "#{get_objects}\n\n"
141
- @engine.log.show data
46
+ # Get the verb's documentation data.
47
+ #
48
+ def self.doc_data
49
+ {
50
+ :name => KEYWORD,
51
+ :shortcut => KEYWORD_SHORT,
52
+ :description => 'Enter the interactive help shell. From there, ' \
53
+ 'look up verbs, object types, settings, the current color ' \
54
+ 'theme, extensions, libraries, and narrative doc pages, or ' \
55
+ 'get detailed help for a specific verb, object, doc page, ' \
56
+ 'loaded library, or loaded extension.',
57
+ :syntax => [ 'help' ],
58
+ :result => "Enters the help shell, prompt \"help> \". Commands: " \
59
+ 'verbs, objects, settings, theme, extensions, libraries, docs ' \
60
+ '(lists — theme also shows a color preview of both palettes), ' \
61
+ 'verb {name}, object {name}, doc {name}, library {name}, ' \
62
+ 'extension {name} (detail for one, tab-completable — library ' \
63
+ '{name} / extension {name} show the README for a loaded core ' \
64
+ "library / user extension). Type 'quit' to leave the shell.",
65
+ :examples => <<~EXAMPLES.strip
66
+ > help
67
+ help> verbs
68
+ help> verb put
69
+ help> object container
70
+ help> theme
71
+ help> docs
72
+ help> doc getting_started
73
+ help> library db
74
+ help> extension alert
75
+ help> quit
76
+ EXAMPLES
77
+ }
142
78
  end
143
79
 
144
- #
145
- # Get the text for the list of verbs.
146
- #
147
- def get_verbs
148
- str = ''
149
- verbs = @engine.dictionary.get_verbs.sort_by( &:keyword )
150
- verbs.each_with_index do |v, i|
151
- cut = v.keyword_shortcut.ljust( 5, ' ' ).yellow
152
- name = v.keyword.ljust( 20, ' ' ).white
153
- str << " #{cut} #{name} \n"
154
- end
155
-
156
- return str
157
- end
158
-
159
- #
160
- # Get the text for the list of objects.
161
- #
162
- def get_objects
163
- str = ''
164
- objs = @engine.dictionary.get_obj_types.sort_by( &:typename )
165
- objs.each_with_index do |o, i|
166
- if o.short_typename != o.typename
167
- short = "(#{o.short_typename})".yellow
168
- name = "#{o.typename.white} #{short}"
169
- else
170
- name = o.typename.white
171
- end
172
- str << " #{name.ljust( 30, ' ' )}\n"
173
- end
174
-
175
- return str
176
- end
177
-
178
- #
179
- # List the extensions
180
- #
181
- def show_ext
182
- data = "\n"
183
- data << " Extensions\n".blue
184
- data << "#{get_extensions}\n\n"
185
- @engine.log.show data
186
- end
187
-
188
- #
189
- # Get the text for the list of extensions.
190
- #
191
- def get_extensions
192
- str = ''
193
- exts = @engine.ext_manager.loaded_extensions.sort
194
- exts.each do |name, ext|
195
- str << " #{name.white} \n"
196
- end
197
-
198
- return str
199
- end
80
+ # ---------------------------------------------------------------------
81
+ # Private functions
82
+ # ---------------------------------------------------------------------
200
83
 
201
- #
202
- # List the libraries
203
- #
204
- def show_lib
205
- data = "\n"
206
- data << " Libraries\n".blue
207
- data << "#{get_libraries}\n\n"
208
- @engine.log.show data
209
- end
84
+ private
210
85
 
211
86
  #
212
- # Get the text for the list of libraries.
87
+ # Build the help shell for this run.
213
88
  #
214
- def get_libraries
215
- str = ''
216
- libs = @engine.lib_manager.loaded_libraries.sort
217
- libs.each do |name, lib|
218
- str << " #{name.white} \n"
219
- end
220
-
221
- return str
89
+ def build_shell
90
+ return Gloo::Docs::HelpShell.new( @engine )
222
91
  end
223
92
 
224
-
225
93
  end
226
94
  end
227
95
  end
data/lib/gloo/verbs/if.rb CHANGED
@@ -101,6 +101,58 @@ module Gloo
101
101
 
102
102
  i.run
103
103
  end
104
+
105
+ # ---------------------------------------------------------------------
106
+ # Verb Documentation
107
+ # ---------------------------------------------------------------------
108
+
109
+ #
110
+ # Get the verb's documentation data.
111
+ #
112
+ def self.doc_data
113
+ {
114
+ :name => KEYWORD,
115
+ :shortcut => KEYWORD_SHORT,
116
+ :description => 'If an expression is true then do something.',
117
+ :syntax => [
118
+ 'if {true} then {do}',
119
+ 'if {true} then {do} else {do else}'
120
+ ],
121
+ :parameters => [
122
+ '{true} — Does the expression evaluate to true?',
123
+ '{do} — Execute command if the expression is true.',
124
+ '{do else} — The else command is optional. Execute command if the expression is false.'
125
+ ],
126
+ :result => 'Unchanged if the expression is not true. If true, ' \
127
+ 'then the result will be based on the command specified ' \
128
+ 'after the then keyword.',
129
+ :errors => [
130
+ "#{MISSING_EXPR_ERR} — No expression is provided as parameter to the verb.",
131
+ 'Other errors depend on the command that is run.'
132
+ ],
133
+ :examples => <<~EXAMPLES.strip
134
+ #
135
+ # If statement example
136
+ #
137
+
138
+ if [container] :
139
+
140
+ x [bool] : false
141
+ true_msg [string] : It is true!
142
+
143
+ on_load [script] :
144
+ if if.x then show "first time: " + if.true_msg
145
+ if ^.x then show 'T' else show 'F'
146
+
147
+ put true into if.x
148
+ if if.x \\
149
+ then show "second time: " + if.true_msg
150
+ if ^.x \\
151
+ then show 'T' \\
152
+ else show 'F'
153
+ EXAMPLES
154
+ }
155
+ end
104
156
  end
105
157
  end
106
158
  end
@@ -3,6 +3,10 @@
3
3
  #
4
4
  # Invoke a function from a script.
5
5
  #
6
+ # Resolution, validation and the actual invoke are all handled by
7
+ # Gloo::Core::Invoker, shared with inline calls inside expressions
8
+ # (see Gloo::Expr::Call) so both go through the same error handling.
9
+ #
6
10
 
7
11
  module Gloo
8
12
  module Verbs
@@ -15,24 +19,10 @@ module Gloo
15
19
  # Run the verb.
16
20
  #
17
21
  def run
18
- if @tokens.token_count > 1
19
- ob = @tokens.first
20
-
21
- # Get the function object
22
- pn = Gloo::Core::Pn.new( @engine, @tokens.second )
23
- func = pn.resolve
24
-
25
- # Is the object a function?
26
- if func&.is_function?
27
- params = get_params_arr
28
-
29
- @engine.log.debug "invoking function: #{func.pn}"
30
- result = func.invoke( params )
31
- @engine.log.debug "function returned: #{result}"
32
- @engine.heap.it.set_to result
33
- return result
34
- end
35
- end
22
+ target = @tokens.token_count > 1 ? @tokens.second : nil
23
+ arg_tokens = @tokens.token_count > 1 ? @tokens.params[ 1..-1 ] : []
24
+
25
+ return Gloo::Core::Invoker.invoke( @engine, target, arg_tokens )
36
26
  end
37
27
 
38
28
  #
@@ -50,29 +40,94 @@ module Gloo
50
40
  end
51
41
 
52
42
  # ---------------------------------------------------------------------
53
- # Private functions
43
+ # Verb Documentation
54
44
  # ---------------------------------------------------------------------
55
45
 
56
- private
57
-
58
46
  #
59
- # Get params array.
47
+ # Get the verb's documentation data.
60
48
  #
61
- def get_params_arr
62
- @engine.log.debug "token params: #{@tokens.params}"
63
- params = @tokens.params[1..-1]
49
+ def self.doc_data
50
+ {
51
+ :name => KEYWORD,
52
+ :shortcut => KEYWORD_SHORT,
53
+ :description => 'Invoke a function. Set it to the result of the function.',
54
+ :syntax => [
55
+ 'invoke {path.to.function} {params}',
56
+ 'invoke( {path.to.function} {params} ) — inline, usable inside any expression',
57
+ '~>( {path.to.function} {params} ) — inline, shortcut spelling'
58
+ ],
59
+ :parameters => [
60
+ '{path.to.function} — The function we want to invoke.',
61
+ '{params} — The list of parameters to the function.'
62
+ ],
63
+ :result => 'The result of the function is put into it. The ' \
64
+ 'inline forms (invoke(...), ~>(...)) can be used anywhere ' \
65
+ 'an expression is evaluated - show, put ... into, if, ' \
66
+ 'unless, eval, and more - and evaluate to the result ' \
67
+ 'directly rather than going through it.',
68
+ :errors => [
69
+ "#{Gloo::Core::Invoker::NO_TARGET_ERR} — No function reference was given.",
70
+ "#{Gloo::Core::Invoker::NOT_FOUND_ERR}{path.to.function} — The path doesn't resolve to any object.",
71
+ "#{Gloo::Core::Invoker::NOT_FUNCTION_ERR}{path.to.function} — The path resolves to an object that isn't a function.",
72
+ "#{Gloo::Core::Invoker::PARAM_COUNT_ERR}{path.to.function} (expected N, got N) — The number of params given doesn't match what the function declares."
73
+ ],
74
+ :notes => 'If the function itself fails during invocation ' \
75
+ '(its on_invoke script hits an error), it is left ' \
76
+ 'unchanged rather than being set to an unreliable result. ' \
77
+ 'The underlying error is whatever was reported by the ' \
78
+ 'failure inside the function. ' \
79
+ 'Inline call params are space-separated, same as the ' \
80
+ 'standalone verb - each one is evaluated as a single ' \
81
+ 'token (a literal or object reference), not a multi-token ' \
82
+ "sub-expression, so invoke( f 3+4 ) won't parse 3+4 as " \
83
+ 'one arg.',
84
+ :examples => <<~EXAMPLES.strip
85
+ #
86
+ # Function examples
87
+ #
88
+
89
+ functions [can] :
90
+
91
+ name [string] : Jasper
92
+
93
+ on_load [script] :
94
+ show 'running function examples' (white)
95
+
96
+ invoke functions.greet ^.name
97
+ show it
98
+
99
+ invoke functions.add 3 4
100
+ show it
64
101
 
65
- @engine.log.info "params: #{params}"
66
- evaluated_params = []
102
+ # Inline, anywhere an expression is evaluated:
103
+ show invoke( functions.add 3 4 )
104
+ put ~>( functions.add 3 4 ) into total
105
+ show "Total: " + invoke( functions.add 3 4 )
67
106
 
68
- params.each do |p|
69
- expr = Gloo::Expr::Expression.new( @engine, [ p ] )
70
- evaluated_params << expr.evaluate
71
- end
107
+ show 'done' (white)
72
108
 
73
- @engine.log.debug "evaluated_params: #{evaluated_params}"
109
+ #
110
+ # Say hi to person (name)
111
+ #
112
+ greet [ƒ] :
113
+ on_invoke [script] :
114
+ put 'Hi, ' + ^.params.name into ^.result
115
+ params [container] :
116
+ name [string] : none
117
+ result [string] :
74
118
 
75
- return evaluated_params
119
+ #
120
+ # Add 2 numbers
121
+ #
122
+ add [ƒ] :
123
+ on_invoke [script] :
124
+ put ^.params.x and ^.params.y into ^.result
125
+ params [container] :
126
+ x [int] :
127
+ y [int] :
128
+ result [string] :
129
+ EXAMPLES
130
+ }
76
131
  end
77
132
 
78
133
  end
@@ -73,16 +73,17 @@ module Gloo
73
73
  # Show object in standard format.
74
74
  #
75
75
  def show_obj( obj, indent = ' ' )
76
+ theme = @engine.theme
76
77
  if obj.multiline_value? && obj.value_is_array?
77
- str = "#{indent}#{obj.name}".white
78
- str << " [#{obj.type_display}] : ".yellow
78
+ str = theme.emphasis( "#{indent}#{obj.name}" )
79
+ str << theme.accent( " [#{obj.type_display}] : " )
79
80
  @engine.log.show str
80
81
  obj.value.each do |line|
81
82
  @engine.log.show "#{indent} #{line}"
82
83
  end
83
84
  else
84
- str = "#{indent}#{obj.name}".white
85
- str << " [#{obj.type_display}] : ".yellow
85
+ str = theme.emphasis( "#{indent}#{obj.name}" )
86
+ str << theme.accent( " [#{obj.type_display}] : " )
86
87
  str << "#{obj.value}"
87
88
  @engine.log.show str
88
89
  end
@@ -114,6 +115,38 @@ module Gloo
114
115
  return ' '
115
116
  end
116
117
 
118
+ # ---------------------------------------------------------------------
119
+ # Verb Documentation
120
+ # ---------------------------------------------------------------------
121
+
122
+ #
123
+ # Get the verb's documentation data.
124
+ #
125
+ def self.doc_data
126
+ {
127
+ :name => KEYWORD,
128
+ :shortcut => KEYWORD_SHORT,
129
+ :description => 'List out objects (and children) at the ' \
130
+ 'current context. When a path is provided, it will be ' \
131
+ 'listed instead of the current context. When using context, ' \
132
+ 'the current context will be shown, but when context has ' \
133
+ 'not been set, the root will be shown.',
134
+ :syntax => [ 'list {path.to.object}' ],
135
+ :parameters => [
136
+ '{path.to.object} — Optional path to object that will be listed. When no path is provided, the current context is used.'
137
+ ],
138
+ :result => 'Object and children are listed out in the CLI.',
139
+ :errors => [
140
+ "#{TARGET_MISSING_ERR}{path.to.object} — The object specified that is to be listed could not be found."
141
+ ],
142
+ :examples => <<~EXAMPLES.strip
143
+ > list
144
+ > list my.container
145
+ > list root
146
+ EXAMPLES
147
+ }
148
+ end
149
+
117
150
  end
118
151
  end
119
152
  end
@@ -77,13 +77,66 @@ module Gloo
77
77
  @engine.ext_manager.load_ext name
78
78
  end
79
79
 
80
- #
80
+ #
81
81
  # Load a library
82
- #
82
+ #
83
83
  def load_library( name )
84
84
  @engine.log.debug "Getting ready to load library: #{name}"
85
85
  @engine.lib_manager.load_lib name
86
86
  end
87
+
88
+ # ---------------------------------------------------------------------
89
+ # Verb Documentation
90
+ # ---------------------------------------------------------------------
91
+
92
+ #
93
+ # Get the verb's documentation data.
94
+ #
95
+ def self.doc_data
96
+ {
97
+ :name => KEYWORD,
98
+ :shortcut => KEYWORD_SHORT,
99
+ :description => 'Load an object file. There are two ways to ' \
100
+ 'specify the file. Give either the full path and file name ' \
101
+ 'or use a relative path from the gloo project folder. For ' \
102
+ 'the latter, the extension is not needed. For the former, ' \
103
+ 'the file extension is necessary. Using * instead of a file ' \
104
+ 'name will load all gloo files in the folder. When using the ' \
105
+ '--app option, the file is loaded from the application ' \
106
+ 'folder, but if not found there, the loader will also look ' \
107
+ 'in the gloo root folder. The load verb is also used to ' \
108
+ 'import an extension or library at runtime.',
109
+ :syntax => [
110
+ 'load {file_name}',
111
+ 'load ext {my_ext}',
112
+ 'load lib {lib_name}'
113
+ ],
114
+ :parameters => [
115
+ '{file_name} — Name of the object file that is to be loaded.',
116
+ 'reference type — By default, the type is file. File can be ' \
117
+ 'specified, but does not need to be. Use ext to load a ' \
118
+ 'User Extension. Use lib to load a Core Library.'
119
+ ],
120
+ :result => 'Objects are loaded into the heap. on_load scripts ' \
121
+ 'are run within the loaded objects.',
122
+ :errors => [
123
+ "#{MISSING_EXPR_ERR} — No expression is provided as parameter to the verb.",
124
+ "#{UNKNOWN_OPT_ERR} — The reference type given isn't file, ext, or lib.",
125
+ "#{WRONG_NUM_ARGS_ERR} — load expects 2 or 3 arguments (the verb, an optional reference type, and the file/ext/lib name)."
126
+ ],
127
+ :examples => <<~EXAMPLES.strip
128
+ > load my/project/file
129
+ > load my/app/*
130
+ > load ~/.my_app/settings.gloo
131
+
132
+ # Load a User Extension
133
+ > load ext my_ext
134
+
135
+ # Load a Core Library
136
+ > load lib db
137
+ EXAMPLES
138
+ }
139
+ end
87
140
  end
88
141
  end
89
142
  end
@@ -85,6 +85,50 @@ module Gloo
85
85
  return Gloo::App::Log::LEVELS[0]
86
86
  end
87
87
 
88
+ # ---------------------------------------------------------------------
89
+ # Verb Documentation
90
+ # ---------------------------------------------------------------------
91
+
92
+ #
93
+ # Get the verb's documentation data.
94
+ #
95
+ def self.doc_data
96
+ {
97
+ :name => KEYWORD,
98
+ :shortcut => KEYWORD_SHORT,
99
+ :description => 'Write to the standard gloo log, or to the gloo error log.',
100
+ :syntax => [ 'log {target} ({level})' ],
101
+ :parameters => [
102
+ '{target} — The message that will be written to the log. ' \
103
+ 'The target might be the path to an object, a literal or ' \
104
+ 'an expression to be evaluated. Level options are: DEBUG, ' \
105
+ 'INFO, WARN, ERROR. Level is an optional parameter — if ' \
106
+ 'not specified, the message is written as DEBUG level.'
107
+ ],
108
+ :result => 'The message is written to the log at the ' \
109
+ 'specified level. It will contain the log message.',
110
+ :notes => "Use `log clear` from the CLI to clear out both the " \
111
+ "standard log and the error log.\n\n" \
112
+ "> log clear",
113
+ :examples => <<~EXAMPLES.strip
114
+ #
115
+ # Show multiple messages in loggers
116
+ #
117
+
118
+ log [can] :
119
+ level [string] : info
120
+ msg [string] : info from var
121
+ on_load [script] :
122
+ log "debug implicit"
123
+ log "debug explicit" (debug)
124
+ log "info" (info)
125
+ log "warn" (warn)
126
+ log "error" (error)
127
+ log log.msg (log.level)
128
+ EXAMPLES
129
+ }
130
+ end
131
+
88
132
  end
89
133
  end
90
134
  end