gloo-lang 1.0.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/lib/VERSION +1 -1
- data/lib/gloo_lang/app/engine.rb +47 -12
- data/lib/gloo_lang/app/log.rb +42 -3
- data/lib/gloo_lang/app/platform.rb +8 -0
- data/lib/gloo_lang/core/heap.rb +2 -2
- data/lib/gloo_lang/persist/disc_mech.rb +87 -0
- data/lib/gloo_lang/persist/file_loader.rb +3 -2
- data/lib/gloo_lang/persist/file_saver.rb +2 -1
- data/lib/gloo_lang/persist/persist_man.rb +6 -19
- metadata +5 -81
- data/Gemfile.lock +0 -68
- data/lib/gloo_lang/app/help.rb +0 -118
- data/lib/gloo_lang/help/app/application.txt +0 -22
- data/lib/gloo_lang/help/app/configuration.txt +0 -7
- data/lib/gloo_lang/help/app/default_help.txt +0 -14
- data/lib/gloo_lang/help/app/logging.txt +0 -16
- data/lib/gloo_lang/help/core/color.txt +0 -31
- data/lib/gloo_lang/help/core/error.txt +0 -33
- data/lib/gloo_lang/help/core/events.txt +0 -21
- data/lib/gloo_lang/help/core/gloo_system.txt +0 -57
- data/lib/gloo_lang/help/core/here.txt +0 -30
- data/lib/gloo_lang/help/core/it.txt +0 -23
- data/lib/gloo_lang/help/core/ops.txt +0 -16
- data/lib/gloo_lang/help/core/pathname.txt +0 -29
- data/lib/gloo_lang/help/objs/basic/alias.txt +0 -36
- data/lib/gloo_lang/help/objs/basic/boolean.txt +0 -28
- data/lib/gloo_lang/help/objs/basic/container.txt +0 -33
- data/lib/gloo_lang/help/objs/basic/decimal.txt +0 -28
- data/lib/gloo_lang/help/objs/basic/integer.txt +0 -27
- data/lib/gloo_lang/help/objs/basic/script.txt +0 -29
- data/lib/gloo_lang/help/objs/basic/string.txt +0 -28
- data/lib/gloo_lang/help/objs/basic/text.txt +0 -27
- data/lib/gloo_lang/help/objs/basic/untyped.txt +0 -22
- data/lib/gloo_lang/help/objs/cli/banner.txt +0 -49
- data/lib/gloo_lang/help/objs/cli/bar.txt +0 -37
- data/lib/gloo_lang/help/objs/cli/colorize.txt +0 -33
- data/lib/gloo_lang/help/objs/cli/confirm.txt +0 -26
- data/lib/gloo_lang/help/objs/cli/menu.txt +0 -44
- data/lib/gloo_lang/help/objs/cli/menu_item.txt +0 -26
- data/lib/gloo_lang/help/objs/cli/pastel.txt +0 -43
- data/lib/gloo_lang/help/objs/cli/prompt.txt +0 -27
- data/lib/gloo_lang/help/objs/cli/select.txt +0 -34
- data/lib/gloo_lang/help/objs/ctrl/each.txt +0 -48
- data/lib/gloo_lang/help/objs/ctrl/repeat.txt +0 -38
- data/lib/gloo_lang/help/objs/data/markdown.txt +0 -25
- data/lib/gloo_lang/help/objs/data/mysql.txt +0 -40
- data/lib/gloo_lang/help/objs/data/query.txt +0 -37
- data/lib/gloo_lang/help/objs/data/sqlite.txt +0 -26
- data/lib/gloo_lang/help/objs/data/table.txt +0 -46
- data/lib/gloo_lang/help/objs/dev/git_repo.txt +0 -36
- data/lib/gloo_lang/help/objs/dev/stats.txt +0 -36
- data/lib/gloo_lang/help/objs/dt/date.txt +0 -23
- data/lib/gloo_lang/help/objs/dt/datetime.txt +0 -24
- data/lib/gloo_lang/help/objs/dt/time.txt +0 -23
- data/lib/gloo_lang/help/objs/ror/erb.txt +0 -37
- data/lib/gloo_lang/help/objs/ror/eval.txt +0 -24
- data/lib/gloo_lang/help/objs/snd/play.txt +0 -23
- data/lib/gloo_lang/help/objs/snd/say.txt +0 -28
- data/lib/gloo_lang/help/objs/system/file.txt +0 -48
- data/lib/gloo_lang/help/objs/system/ssh_exec.txt +0 -30
- data/lib/gloo_lang/help/objs/system/system.txt +0 -32
- data/lib/gloo_lang/help/objs/web/http_get.txt +0 -35
- data/lib/gloo_lang/help/objs/web/http_post.txt +0 -34
- data/lib/gloo_lang/help/objs/web/json.txt +0 -34
- data/lib/gloo_lang/help/objs/web/slack.txt +0 -33
- data/lib/gloo_lang/help/objs/web/teams.txt +0 -30
- data/lib/gloo_lang/help/objs/web/uri.txt +0 -38
- data/lib/gloo_lang/help/verbs/alert.txt +0 -33
- data/lib/gloo_lang/help/verbs/beep.txt +0 -25
- data/lib/gloo_lang/help/verbs/cls.txt +0 -24
- data/lib/gloo_lang/help/verbs/context.txt +0 -43
- data/lib/gloo_lang/help/verbs/create.txt +0 -33
- data/lib/gloo_lang/help/verbs/execute.txt +0 -27
- data/lib/gloo_lang/help/verbs/help.txt +0 -34
- data/lib/gloo_lang/help/verbs/if.txt +0 -37
- data/lib/gloo_lang/help/verbs/list.txt +0 -34
- data/lib/gloo_lang/help/verbs/load.txt +0 -38
- data/lib/gloo_lang/help/verbs/move.txt +0 -42
- data/lib/gloo_lang/help/verbs/put.txt +0 -38
- data/lib/gloo_lang/help/verbs/quit.txt +0 -25
- data/lib/gloo_lang/help/verbs/run.txt +0 -41
- data/lib/gloo_lang/help/verbs/save.txt +0 -26
- data/lib/gloo_lang/help/verbs/show.txt +0 -30
- data/lib/gloo_lang/help/verbs/tell.txt +0 -34
- data/lib/gloo_lang/help/verbs/unless.txt +0 -38
- data/lib/gloo_lang/help/verbs/version.txt +0 -32
- data/lib/gloo_lang/help/verbs/wait.txt +0 -29
- data/lib/gloo_lang/verbs/help.rb +0 -264
- data/lib/gloo_lang/verbs/version.rb +0 -37
data/lib/gloo_lang/verbs/help.rb
DELETED
@@ -1,264 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Show the help information.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Verbs
|
9
|
-
class Help < GlooLang::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'help'.freeze
|
12
|
-
KEYWORD_SHORT = '?'.freeze
|
13
|
-
DEFAULT_HELP = 'default_help'.freeze
|
14
|
-
HELP_NOT_FOUND_ERR = 'Help command could not be found:'.freeze
|
15
|
-
|
16
|
-
DISPATCH = {
|
17
|
-
settings: 'show_settings',
|
18
|
-
keywords: 'show_keywords',
|
19
|
-
verb: 'show_verbs',
|
20
|
-
verbs: 'show_verbs',
|
21
|
-
v: 'show_verbs',
|
22
|
-
obj: 'show_objs',
|
23
|
-
object: 'show_objs',
|
24
|
-
objects: 'show_objs',
|
25
|
-
o: 'show_objs',
|
26
|
-
topics: 'show_topics'
|
27
|
-
}.freeze
|
28
|
-
|
29
|
-
#
|
30
|
-
# Run the verb.
|
31
|
-
#
|
32
|
-
def run
|
33
|
-
opts = @tokens.second if @tokens
|
34
|
-
opts = opts.strip.downcase if opts
|
35
|
-
|
36
|
-
if opts
|
37
|
-
dispatch opts
|
38
|
-
else
|
39
|
-
@engine.help.page_topic DEFAULT_HELP
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Get the text for the list of verbs.
|
45
|
-
#
|
46
|
-
def get_verb_list
|
47
|
-
out = "Verbs:\n"
|
48
|
-
str = ''
|
49
|
-
verbs = @engine.dictionary.get_verbs.sort_by( &:keyword )
|
50
|
-
verbs.each_with_index do |v, i|
|
51
|
-
cut = v.keyword_shortcut.ljust( 5, ' ' )
|
52
|
-
str << " #{cut} #{v.keyword.ljust( 20, ' ' )}"
|
53
|
-
if ( ( i + 1 ) % 3 ).zero?
|
54
|
-
out << "#{str}\n"
|
55
|
-
str = ''
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
return out
|
60
|
-
end
|
61
|
-
|
62
|
-
#
|
63
|
-
# Lookup the opts in the dispatch table.
|
64
|
-
#
|
65
|
-
def lookup_opts( opts )
|
66
|
-
return DISPATCH[ opts.to_sym ]
|
67
|
-
end
|
68
|
-
|
69
|
-
#
|
70
|
-
# Get the text for the list of verbs.
|
71
|
-
#
|
72
|
-
def get_obj_list
|
73
|
-
out = "Object Types:\n"
|
74
|
-
str = ''
|
75
|
-
objs = @engine.dictionary.get_obj_types.sort_by( &:typename )
|
76
|
-
objs.each_with_index do |o, i|
|
77
|
-
name = o.typename
|
78
|
-
if o.short_typename != o.typename
|
79
|
-
name = "#{name} (#{o.short_typename})"
|
80
|
-
end
|
81
|
-
str << " #{name.ljust( 30, ' ' )}"
|
82
|
-
if ( ( i + 1 ) % 4 ).zero?
|
83
|
-
out << "#{str}\n"
|
84
|
-
str = ''
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
return out
|
89
|
-
end
|
90
|
-
|
91
|
-
#
|
92
|
-
# Get the list of help topics.
|
93
|
-
#
|
94
|
-
def get_topics
|
95
|
-
out = "Help Topics:\n"
|
96
|
-
str = ''
|
97
|
-
objs = @engine.help.topics.keys.sort
|
98
|
-
objs.each_with_index do |o, i|
|
99
|
-
str << " #{o.ljust( 30, ' ' )}"
|
100
|
-
if ( ( i + 1 ) % 4 ).zero?
|
101
|
-
out << "#{str}\n"
|
102
|
-
str = ''
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
return out
|
107
|
-
end
|
108
|
-
|
109
|
-
#
|
110
|
-
# Get the Verb's keyword.
|
111
|
-
#
|
112
|
-
def self.keyword
|
113
|
-
return KEYWORD
|
114
|
-
end
|
115
|
-
|
116
|
-
#
|
117
|
-
# Get the Verb's keyword shortcut.
|
118
|
-
#
|
119
|
-
def self.keyword_shortcut
|
120
|
-
return KEYWORD_SHORT
|
121
|
-
end
|
122
|
-
|
123
|
-
# ---------------------------------------------------------------------
|
124
|
-
# Private functions
|
125
|
-
# ---------------------------------------------------------------------
|
126
|
-
|
127
|
-
private
|
128
|
-
|
129
|
-
#
|
130
|
-
# Report an error with the inline help.
|
131
|
-
#
|
132
|
-
def report_help_error( opts )
|
133
|
-
@engine.err "#{HELP_NOT_FOUND_ERR} '#{opts}'"
|
134
|
-
end
|
135
|
-
|
136
|
-
#
|
137
|
-
# Dispatch the help to the right place.
|
138
|
-
#
|
139
|
-
def dispatch( opts )
|
140
|
-
return if dispatch_help_page( opts )
|
141
|
-
|
142
|
-
@engine.log.debug 'looking for built in help topic'
|
143
|
-
cmd = DISPATCH[ opts.to_sym ]
|
144
|
-
if cmd
|
145
|
-
@engine.log.debug 'found help index'
|
146
|
-
send cmd
|
147
|
-
else
|
148
|
-
@engine.log.debug 'looking for entity help'
|
149
|
-
entity_help opts
|
150
|
-
end
|
151
|
-
rescue
|
152
|
-
report_help_error opts
|
153
|
-
end
|
154
|
-
|
155
|
-
#
|
156
|
-
# Dispatch to a help page if we can find one.
|
157
|
-
#
|
158
|
-
def dispatch_help_page( opts )
|
159
|
-
if @engine.help.topic? opts
|
160
|
-
@engine.log.debug 'found expanded help topic'
|
161
|
-
@engine.help.page_topic opts
|
162
|
-
return true
|
163
|
-
end
|
164
|
-
|
165
|
-
key = @engine.dictionary.lookup_keyword opts
|
166
|
-
if @engine.help.topic? key
|
167
|
-
@engine.log.debug 'found expanded help topic'
|
168
|
-
@engine.help.page_topic key
|
169
|
-
return true
|
170
|
-
end
|
171
|
-
|
172
|
-
return false
|
173
|
-
end
|
174
|
-
|
175
|
-
#
|
176
|
-
# Write output to it and show it unless we are in
|
177
|
-
# silent mode.
|
178
|
-
#
|
179
|
-
def show_output( out )
|
180
|
-
@engine.heap.it.set_to out
|
181
|
-
puts out unless @engine.args.quiet?
|
182
|
-
end
|
183
|
-
|
184
|
-
#
|
185
|
-
# List all help topics (articles)
|
186
|
-
#
|
187
|
-
def show_topics
|
188
|
-
out = self.get_topics
|
189
|
-
show_output out
|
190
|
-
end
|
191
|
-
|
192
|
-
#
|
193
|
-
# Dispatch the help command to a verb or object
|
194
|
-
# if we can find one matching the request.
|
195
|
-
#
|
196
|
-
def entity_help( opts )
|
197
|
-
return if try_verb_help opts
|
198
|
-
return if try_object_help opts
|
199
|
-
|
200
|
-
report_help_error opts
|
201
|
-
end
|
202
|
-
|
203
|
-
#
|
204
|
-
# See if there is a verb we can show help
|
205
|
-
# information about.
|
206
|
-
#
|
207
|
-
def try_verb_help( opts )
|
208
|
-
if @engine.dictionary.verb?( opts )
|
209
|
-
t = @engine.dictionary.find_verb( opts )
|
210
|
-
out = t.send 'help'
|
211
|
-
show_output out
|
212
|
-
return true
|
213
|
-
end
|
214
|
-
|
215
|
-
return false
|
216
|
-
end
|
217
|
-
|
218
|
-
#
|
219
|
-
# See if there is a verb we can show help
|
220
|
-
# information about.
|
221
|
-
#
|
222
|
-
def try_object_help( opts )
|
223
|
-
if @engine.dictionary.obj?( opts )
|
224
|
-
t = @engine.dictionary.find_obj( opts )
|
225
|
-
out = t.send 'help'
|
226
|
-
show_output out
|
227
|
-
return true
|
228
|
-
end
|
229
|
-
|
230
|
-
return false
|
231
|
-
end
|
232
|
-
|
233
|
-
#
|
234
|
-
# Show application settings.
|
235
|
-
#
|
236
|
-
def show_settings
|
237
|
-
@engine.settings.show
|
238
|
-
end
|
239
|
-
|
240
|
-
#
|
241
|
-
# Show all keywords: verbs and objects.
|
242
|
-
#
|
243
|
-
def show_keywords
|
244
|
-
@engine.dictionary.show_keywords
|
245
|
-
end
|
246
|
-
|
247
|
-
#
|
248
|
-
# List the verbs
|
249
|
-
#
|
250
|
-
def show_verbs
|
251
|
-
show_output get_verb_list
|
252
|
-
end
|
253
|
-
|
254
|
-
#
|
255
|
-
# List the object types
|
256
|
-
#
|
257
|
-
def show_objs
|
258
|
-
out = self.get_obj_list
|
259
|
-
show_output out
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|
263
|
-
end
|
264
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Show the current application version.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Verbs
|
9
|
-
class Version < GlooLang::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'version'.freeze
|
12
|
-
KEYWORD_SHORT = 'v'.freeze
|
13
|
-
|
14
|
-
#
|
15
|
-
# Run the verb.
|
16
|
-
#
|
17
|
-
def run
|
18
|
-
@engine.log.show GlooLang::App::Info.full_version
|
19
|
-
end
|
20
|
-
|
21
|
-
#
|
22
|
-
# Get the Verb's keyword.
|
23
|
-
#
|
24
|
-
def self.keyword
|
25
|
-
return KEYWORD
|
26
|
-
end
|
27
|
-
|
28
|
-
#
|
29
|
-
# Get the Verb's keyword shortcut.
|
30
|
-
#
|
31
|
-
def self.keyword_shortcut
|
32
|
-
return KEYWORD_SHORT
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|