gloo 1.4.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/.gitignore +1 -0
- data/gloo.gemspec +0 -2
- data/lib/VERSION +1 -1
- data/lib/dependencies.rb +4 -4
- data/lib/gloo/app/args.rb +112 -0
- data/lib/gloo/app/engine.rb +247 -0
- data/lib/gloo/app/engine_context.rb +25 -0
- data/lib/gloo/app/info.rb +20 -3
- data/lib/gloo/app/log.rb +73 -1
- data/lib/gloo/app/mode.rb +27 -0
- data/lib/gloo/app/platform.rb +8 -1
- data/lib/gloo/app/settings.rb +202 -0
- data/lib/gloo/convert/converter.rb +42 -0
- data/lib/gloo/convert/string_to_date.rb +21 -0
- data/lib/gloo/convert/string_to_datetime.rb +21 -0
- data/lib/gloo/convert/string_to_decimal.rb +20 -0
- data/lib/gloo/convert/string_to_integer.rb +20 -0
- data/lib/gloo/convert/string_to_time.rb +21 -0
- data/lib/gloo/core/baseo.rb +31 -0
- data/lib/gloo/core/dictionary.rb +245 -0
- data/lib/gloo/core/error.rb +61 -0
- data/lib/gloo/core/event_manager.rb +45 -0
- data/lib/gloo/core/factory.rb +211 -0
- data/lib/gloo/core/gloo_system.rb +267 -0
- data/lib/gloo/core/heap.rb +53 -0
- data/lib/gloo/core/here.rb +36 -0
- data/lib/gloo/core/it.rb +36 -0
- data/lib/gloo/core/literal.rb +30 -0
- data/lib/gloo/core/obj.rb +318 -0
- data/lib/gloo/core/obj_finder.rb +30 -0
- data/lib/gloo/core/op.rb +40 -0
- data/lib/gloo/core/parser.rb +60 -0
- data/lib/gloo/core/pn.rb +212 -0
- data/lib/gloo/core/tokens.rb +165 -0
- data/lib/gloo/core/verb.rb +87 -0
- data/lib/gloo/exec/action.rb +48 -0
- data/lib/gloo/exec/dispatch.rb +40 -0
- data/lib/gloo/exec/exec_env.rb +75 -0
- data/lib/gloo/exec/runner.rb +45 -0
- data/lib/gloo/exec/script.rb +50 -0
- data/lib/gloo/exec/stack.rb +79 -0
- data/lib/gloo/expr/expression.rb +119 -0
- data/lib/gloo/expr/l_boolean.rb +36 -0
- data/lib/gloo/expr/l_decimal.rb +39 -0
- data/lib/gloo/expr/l_integer.rb +37 -0
- data/lib/gloo/expr/l_string.rb +58 -0
- data/lib/gloo/expr/op_div.rb +22 -0
- data/lib/gloo/expr/op_minus.rb +22 -0
- data/lib/gloo/expr/op_mult.rb +22 -0
- data/lib/gloo/expr/op_plus.rb +24 -0
- data/lib/gloo/objs/basic/alias.rb +78 -0
- data/lib/gloo/objs/basic/boolean.rb +120 -0
- data/lib/gloo/objs/basic/container.rb +65 -0
- data/lib/gloo/objs/basic/decimal.rb +76 -0
- data/lib/gloo/objs/basic/integer.rb +73 -0
- data/lib/gloo/objs/basic/script.rb +99 -0
- data/lib/gloo/objs/basic/string.rb +77 -0
- data/lib/gloo/objs/basic/text.rb +79 -0
- data/lib/gloo/objs/basic/untyped.rb +41 -0
- data/lib/gloo/objs/cli/banner.rb +1 -1
- data/lib/gloo/objs/cli/bar.rb +3 -3
- data/lib/gloo/objs/cli/colorize.rb +1 -1
- data/lib/gloo/objs/cli/confirm.rb +1 -1
- data/lib/gloo/objs/cli/menu.rb +6 -6
- data/lib/gloo/objs/cli/menu_item.rb +1 -1
- data/lib/gloo/objs/cli/pastel.rb +1 -1
- data/lib/gloo/objs/cli/prompt.rb +1 -1
- data/lib/gloo/objs/cli/select.rb +2 -2
- data/lib/gloo/objs/ctrl/each.rb +279 -0
- data/lib/gloo/objs/ctrl/repeat.rb +108 -0
- data/lib/gloo/objs/data/markdown.rb +79 -0
- data/lib/gloo/objs/data/mysql.rb +5 -5
- data/lib/gloo/objs/data/query.rb +4 -4
- data/lib/gloo/objs/data/sqlite.rb +1 -1
- data/lib/gloo/objs/data/table.rb +112 -0
- data/lib/gloo/objs/dev/git.rb +2 -2
- data/lib/gloo/objs/dev/stats.rb +4 -4
- data/lib/gloo/objs/dt/date.rb +65 -0
- data/lib/gloo/objs/dt/datetime.rb +120 -0
- data/lib/gloo/objs/dt/dt_tools.rb +100 -0
- data/lib/gloo/objs/dt/time.rb +65 -0
- data/lib/gloo/objs/ror/erb.rb +116 -0
- data/lib/gloo/objs/ror/eval.rb +107 -0
- data/lib/gloo/objs/snd/play.rb +1 -1
- data/lib/gloo/objs/snd/say.rb +1 -1
- data/lib/gloo/objs/system/file_handle.rb +4 -4
- data/lib/gloo/objs/system/ssh_exec.rb +1 -1
- data/lib/gloo/objs/system/system.rb +1 -1
- data/lib/gloo/objs/web/http_get.rb +159 -0
- data/lib/gloo/objs/web/http_post.rb +183 -0
- data/lib/gloo/objs/web/json.rb +135 -0
- data/lib/gloo/objs/web/slack.rb +130 -0
- data/lib/gloo/objs/web/teams.rb +117 -0
- data/lib/gloo/objs/web/uri.rb +148 -0
- data/lib/gloo/persist/disc_mech.rb +87 -0
- data/lib/gloo/persist/file_loader.rb +193 -0
- data/lib/gloo/persist/file_saver.rb +51 -0
- data/lib/gloo/persist/file_storage.rb +46 -0
- data/lib/gloo/persist/line_splitter.rb +81 -0
- data/lib/gloo/persist/persist_man.rb +153 -0
- data/lib/gloo/utils/format.rb +21 -0
- data/lib/gloo/utils/stats.rb +206 -0
- data/lib/gloo/utils/words.rb +19 -0
- data/lib/gloo/verbs/alert.rb +2 -2
- data/lib/gloo/verbs/beep.rb +1 -1
- data/lib/gloo/verbs/cls.rb +1 -1
- data/lib/gloo/verbs/context.rb +62 -0
- data/lib/gloo/verbs/create.rb +68 -0
- data/lib/gloo/verbs/execute.rb +56 -0
- data/lib/gloo/verbs/files.rb +49 -0
- data/lib/gloo/verbs/help.rb +1 -1
- data/lib/gloo/verbs/if.rb +92 -0
- data/lib/gloo/verbs/list.rb +98 -0
- data/lib/gloo/verbs/load.rb +45 -0
- data/lib/gloo/verbs/move.rb +89 -0
- data/lib/gloo/verbs/put.rb +94 -0
- data/lib/gloo/verbs/quit.rb +40 -0
- data/lib/gloo/verbs/reload.rb +43 -0
- data/lib/gloo/verbs/run.rb +75 -0
- data/lib/gloo/verbs/save.rb +39 -0
- data/lib/gloo/verbs/show.rb +63 -0
- data/lib/gloo/verbs/tell.rb +80 -0
- data/lib/gloo/verbs/unless.rb +92 -0
- data/lib/gloo/verbs/unload.rb +46 -0
- data/lib/gloo/verbs/version.rb +3 -3
- data/lib/gloo/verbs/wait.rb +42 -0
- data/lib/gloo.rb +2 -2
- data/lib/run.rb +2 -2
- metadata +97 -22
@@ -0,0 +1,92 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# If something is true, do something.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class If < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'if'.freeze
|
12
|
+
KEYWORD_SHORT = 'if'.freeze
|
13
|
+
THEN = 'then'.freeze
|
14
|
+
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
15
|
+
|
16
|
+
#
|
17
|
+
# Run the verb.
|
18
|
+
#
|
19
|
+
def run
|
20
|
+
value = value_tokens
|
21
|
+
return if value.nil?
|
22
|
+
|
23
|
+
return unless evals_true( value )
|
24
|
+
|
25
|
+
run_then
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Get the Verb's keyword.
|
30
|
+
#
|
31
|
+
def self.keyword
|
32
|
+
return KEYWORD
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Get the Verb's keyword shortcut.
|
37
|
+
#
|
38
|
+
def self.keyword_shortcut
|
39
|
+
return KEYWORD_SHORT
|
40
|
+
end
|
41
|
+
|
42
|
+
# ---------------------------------------------------------------------
|
43
|
+
# Private functions
|
44
|
+
# ---------------------------------------------------------------------
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get the list of tokens that represent the parameters
|
50
|
+
# of the if command.
|
51
|
+
#
|
52
|
+
def value_tokens
|
53
|
+
value = @tokens.before_token( THEN )
|
54
|
+
if value && value.count > 1
|
55
|
+
# The first token is the verb, so we drop it.
|
56
|
+
value = value[ 1..-1 ]
|
57
|
+
else
|
58
|
+
@engine.err MISSING_EXPR_ERR
|
59
|
+
end
|
60
|
+
|
61
|
+
return value
|
62
|
+
end
|
63
|
+
|
64
|
+
#
|
65
|
+
# Does the given value evalute to true?
|
66
|
+
#
|
67
|
+
def evals_true( value )
|
68
|
+
eval_result = false
|
69
|
+
if value.count.positive?
|
70
|
+
expr = Gloo::Expr::Expression.new( @engine, value )
|
71
|
+
result = expr.evaluate
|
72
|
+
eval_result = true if result == true
|
73
|
+
eval_result = true if result.is_a?( Numeric ) && result != 0
|
74
|
+
end
|
75
|
+
|
76
|
+
return eval_result
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Run the 'then' command.
|
81
|
+
#
|
82
|
+
def run_then
|
83
|
+
cmd = @tokens.expr_after( THEN )
|
84
|
+
i = @engine.parser.parse_immediate cmd
|
85
|
+
return unless i
|
86
|
+
|
87
|
+
i.run
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# List out an object and it's children.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class List < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'list'.freeze
|
12
|
+
KEYWORD_SHORT = '.'.freeze
|
13
|
+
TARGET_MISSING_ERR = 'Object does not exist: '.freeze
|
14
|
+
|
15
|
+
#
|
16
|
+
# Run the verb.
|
17
|
+
#
|
18
|
+
def run
|
19
|
+
levels = determine_levels
|
20
|
+
target = self.determine_target
|
21
|
+
obj = target.resolve
|
22
|
+
if obj
|
23
|
+
show_target( obj, levels )
|
24
|
+
else
|
25
|
+
@engine.err "#{TARGET_MISSING_ERR} #{target}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Determine the target object for the show command.
|
31
|
+
#
|
32
|
+
def determine_target
|
33
|
+
return @engine.heap.context if @tokens.token_count == 1
|
34
|
+
|
35
|
+
return Gloo::Core::Pn.new( @engine, @tokens.second )
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Get the Verb's keyword.
|
40
|
+
#
|
41
|
+
def self.keyword
|
42
|
+
return KEYWORD
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Get the Verb's keyword shortcut.
|
47
|
+
#
|
48
|
+
def self.keyword_shortcut
|
49
|
+
return KEYWORD_SHORT
|
50
|
+
end
|
51
|
+
|
52
|
+
# ---------------------------------------------------------------------
|
53
|
+
# Private functions
|
54
|
+
# ---------------------------------------------------------------------
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
#
|
59
|
+
# Show the target object.
|
60
|
+
#
|
61
|
+
def show_target( obj, levels, indent = '' )
|
62
|
+
show_obj( obj, indent )
|
63
|
+
return if levels.zero?
|
64
|
+
|
65
|
+
obj.children.each do |o|
|
66
|
+
show_target( o, levels - 1, "#{indent} " )
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#
|
71
|
+
# Show object in standard format.
|
72
|
+
#
|
73
|
+
def show_obj( obj, indent = ' ' )
|
74
|
+
if obj.multiline_value? && obj.value_is_array?
|
75
|
+
@engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] :"
|
76
|
+
obj.value.each do |line|
|
77
|
+
@engine.log.show "#{indent} #{line}"
|
78
|
+
end
|
79
|
+
else
|
80
|
+
@engine.log.show "#{indent}#{obj.name} [#{obj.type_display}] : #{obj.value}"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
#
|
85
|
+
# Determine how many levels to show.
|
86
|
+
#
|
87
|
+
def determine_levels
|
88
|
+
# Check settings for the default value.
|
89
|
+
levels = @engine.settings.list_indent
|
90
|
+
return levels if levels
|
91
|
+
|
92
|
+
# Last chance: use the default
|
93
|
+
return 1
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Save an object to a file or other persistance mechcanism.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Load < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'load'.freeze
|
12
|
+
KEYWORD_SHORT = '<'.freeze
|
13
|
+
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
14
|
+
|
15
|
+
#
|
16
|
+
# Run the verb.
|
17
|
+
#
|
18
|
+
def run
|
19
|
+
fn = @tokens.second
|
20
|
+
|
21
|
+
if fn
|
22
|
+
@engine.log.debug "Getting ready to load file: #{fn}"
|
23
|
+
@engine.persist_man.load fn
|
24
|
+
else
|
25
|
+
@engine.err MISSING_EXPR_ERR
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
#
|
30
|
+
# Get the Verb's keyword.
|
31
|
+
#
|
32
|
+
def self.keyword
|
33
|
+
return KEYWORD
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Get the Verb's keyword shortcut.
|
38
|
+
#
|
39
|
+
def self.keyword_shortcut
|
40
|
+
return KEYWORD_SHORT
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Move an object to a new parent.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Move < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'move'.freeze
|
12
|
+
KEYWORD_SHORT = 'mv'.freeze
|
13
|
+
TO = 'to'.freeze
|
14
|
+
MISSING_SRC_ERR = 'Object to move was not specified!'.freeze
|
15
|
+
MISSING_SRC_OBJ_ERR = 'Could not find object to move: '.freeze
|
16
|
+
MISSING_DST_ERR = "Move' must include 'to' parent object!".freeze
|
17
|
+
MISSING_DST_OBJ_ERR = 'Could not resolve target: '.freeze
|
18
|
+
|
19
|
+
#
|
20
|
+
# Run the verb.
|
21
|
+
#
|
22
|
+
def run
|
23
|
+
dst = lookup_dst
|
24
|
+
return if dst.nil?
|
25
|
+
|
26
|
+
o = lookup_obj
|
27
|
+
return unless o
|
28
|
+
|
29
|
+
o.parent.remove_child o
|
30
|
+
dst.add_child o
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Get the Verb's keyword.
|
35
|
+
#
|
36
|
+
def self.keyword
|
37
|
+
return KEYWORD
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get the Verb's keyword shortcut.
|
42
|
+
#
|
43
|
+
def self.keyword_shortcut
|
44
|
+
return KEYWORD_SHORT
|
45
|
+
end
|
46
|
+
|
47
|
+
# ---------------------------------------------------------------------
|
48
|
+
# Private functions
|
49
|
+
# ---------------------------------------------------------------------
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
#
|
54
|
+
# Lookup the object that we're moving.
|
55
|
+
#
|
56
|
+
def lookup_obj
|
57
|
+
arr = @tokens.before_token( TO )
|
58
|
+
if arr.count == 1
|
59
|
+
@engine.err MISSING_SRC_ERR
|
60
|
+
return
|
61
|
+
end
|
62
|
+
|
63
|
+
name = arr[ 1 ]
|
64
|
+
pn = Gloo::Core::Pn.new( @engine, name )
|
65
|
+
o = pn.resolve
|
66
|
+
|
67
|
+
@engine.err( "#{MISSING_SRC_OBJ_ERR} #{name}" ) unless o
|
68
|
+
return o
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Lookup destination, the new parent object.
|
73
|
+
#
|
74
|
+
def lookup_dst
|
75
|
+
dst = @tokens.after_token( TO )
|
76
|
+
unless dst
|
77
|
+
@engine.err MISSING_DST_ERR
|
78
|
+
return nil
|
79
|
+
end
|
80
|
+
|
81
|
+
pn = Gloo::Core::Pn.new( @engine, dst )
|
82
|
+
o = pn.resolve
|
83
|
+
@engine.err( "#{MISSING_DST_OBJ_ERR} '#{dst}'" ) unless o
|
84
|
+
return o
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Create an object, optionally of a type.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Put < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'put'.freeze
|
12
|
+
KEYWORD_SHORT = 'p'.freeze
|
13
|
+
INTO = 'into'.freeze
|
14
|
+
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
15
|
+
INTO_MISSING_ERR = 'Target (into) missing!'.freeze
|
16
|
+
TARGET_ERR = 'Target could not be resolved: '.freeze
|
17
|
+
|
18
|
+
#
|
19
|
+
# Run the verb.
|
20
|
+
#
|
21
|
+
def run
|
22
|
+
value = fetch_value_tokens
|
23
|
+
return if value.nil?
|
24
|
+
|
25
|
+
target = lookup_target
|
26
|
+
return if target.nil?
|
27
|
+
|
28
|
+
update_target target, value
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Get the Verb's keyword.
|
33
|
+
#
|
34
|
+
def self.keyword
|
35
|
+
return KEYWORD
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Get the Verb's keyword shortcut.
|
40
|
+
#
|
41
|
+
def self.keyword_shortcut
|
42
|
+
return KEYWORD_SHORT
|
43
|
+
end
|
44
|
+
|
45
|
+
# ---------------------------------------------------------------------
|
46
|
+
# Private functions
|
47
|
+
# ---------------------------------------------------------------------
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
#
|
52
|
+
# Get the value that is being put.
|
53
|
+
#
|
54
|
+
def fetch_value_tokens
|
55
|
+
value = @tokens.before_token( INTO )
|
56
|
+
if value.nil? || ( value.count <= 1 )
|
57
|
+
@engine.err MISSING_EXPR_ERR
|
58
|
+
return nil
|
59
|
+
end
|
60
|
+
|
61
|
+
# The first token is the verb, so we drop it.
|
62
|
+
return value[ 1..-1 ]
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# Lookup the target of the put command.
|
67
|
+
#
|
68
|
+
def lookup_target
|
69
|
+
target = @tokens.after_token( INTO )
|
70
|
+
return target if target
|
71
|
+
|
72
|
+
@engine.err INTO_MISSING_ERR
|
73
|
+
return nil
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Update the target with the new value.
|
78
|
+
#
|
79
|
+
def update_target( target, value )
|
80
|
+
pn = Gloo::Core::Pn.new( @engine, target )
|
81
|
+
o = pn.resolve
|
82
|
+
if o.nil?
|
83
|
+
@engine.err "#{TARGET_ERR} #{target}"
|
84
|
+
elsif value.count.positive?
|
85
|
+
expr = Gloo::Expr::Expression.new( @engine, value )
|
86
|
+
result = expr.evaluate
|
87
|
+
o.set_value result
|
88
|
+
@engine.heap.it.set_to result
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Quit the running gloo engine.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Quit < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'quit'.freeze
|
12
|
+
KEYWORD_SHORT = 'q'.freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
# We'll mark the application as not running and let the
|
18
|
+
# engine stop gracefully next time through the loop.
|
19
|
+
#
|
20
|
+
def run
|
21
|
+
@engine.stop_running
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Get the Verb's keyword.
|
26
|
+
#
|
27
|
+
def self.keyword
|
28
|
+
return KEYWORD
|
29
|
+
end
|
30
|
+
|
31
|
+
#
|
32
|
+
# Get the Verb's keyword shortcut.
|
33
|
+
#
|
34
|
+
def self.keyword_shortcut
|
35
|
+
return KEYWORD_SHORT
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Reload all files.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Reload < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'reload'.freeze
|
12
|
+
KEYWORD_SHORT = 'r!'.freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
@engine.persist_man.reload_all
|
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
|
+
# ---------------------------------------------------------------------
|
36
|
+
# Private functions
|
37
|
+
# ---------------------------------------------------------------------
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Run a script.
|
5
|
+
# Shortcut for telling a script to run.
|
6
|
+
#
|
7
|
+
|
8
|
+
module Gloo
|
9
|
+
module Verbs
|
10
|
+
class Run < Gloo::Core::Verb
|
11
|
+
|
12
|
+
KEYWORD = 'run'.freeze
|
13
|
+
KEYWORD_SHORT = 'r'.freeze
|
14
|
+
EVALUATE_RUN = '~>'.freeze
|
15
|
+
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
16
|
+
|
17
|
+
#
|
18
|
+
# Run the verb.
|
19
|
+
#
|
20
|
+
def run
|
21
|
+
if @tokens.token_count < 2
|
22
|
+
@engine.err MISSING_EXPR_ERR
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
if @tokens.second == EVALUATE_RUN
|
27
|
+
run_expression
|
28
|
+
else
|
29
|
+
run_script
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
#
|
34
|
+
# Get the Verb's keyword.
|
35
|
+
#
|
36
|
+
def self.keyword
|
37
|
+
return KEYWORD
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get the Verb's keyword shortcut.
|
42
|
+
#
|
43
|
+
def self.keyword_shortcut
|
44
|
+
return KEYWORD_SHORT
|
45
|
+
end
|
46
|
+
|
47
|
+
# ---------------------------------------------------------------------
|
48
|
+
# Private functions
|
49
|
+
# ---------------------------------------------------------------------
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
#
|
54
|
+
# Run a script specified by pathname
|
55
|
+
#
|
56
|
+
def run_script
|
57
|
+
Gloo::Exec::Runner.run( @engine, @tokens.second )
|
58
|
+
end
|
59
|
+
|
60
|
+
#
|
61
|
+
# Evaluate an expression and run that.
|
62
|
+
#
|
63
|
+
def run_expression
|
64
|
+
unless @tokens.token_count > 2
|
65
|
+
@engine.err MISSING_EXPR_ERR
|
66
|
+
return
|
67
|
+
end
|
68
|
+
|
69
|
+
expr = Gloo::Expr::Expression.new( @engine, @tokens.params[ 1..-1 ] )
|
70
|
+
@engine.parser.run expr.evaluate
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Save an object to a file or other persistance mechcanism.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Save < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'save'.freeze
|
12
|
+
KEYWORD_SHORT = '>'.freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
# TODO: Not currently using folders or keeping
|
19
|
+
# track of where the object was loaded from.
|
20
|
+
@engine.persist_man.save @tokens.second
|
21
|
+
end
|
22
|
+
|
23
|
+
#
|
24
|
+
# Get the Verb's keyword.
|
25
|
+
#
|
26
|
+
def self.keyword
|
27
|
+
return KEYWORD
|
28
|
+
end
|
29
|
+
|
30
|
+
#
|
31
|
+
# Get the Verb's keyword shortcut.
|
32
|
+
#
|
33
|
+
def self.keyword_shortcut
|
34
|
+
return KEYWORD_SHORT
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Show a single object's value.
|
5
|
+
#
|
6
|
+
|
7
|
+
module Gloo
|
8
|
+
module Verbs
|
9
|
+
class Show < Gloo::Core::Verb
|
10
|
+
|
11
|
+
KEYWORD = 'show'.freeze
|
12
|
+
KEYWORD_SHORT = '='.freeze
|
13
|
+
|
14
|
+
#
|
15
|
+
# Run the verb.
|
16
|
+
#
|
17
|
+
def run
|
18
|
+
if @tokens.token_count > 1
|
19
|
+
expr = Gloo::Expr::Expression.new( @engine, @tokens.params )
|
20
|
+
result = expr.evaluate
|
21
|
+
@engine.log.show get_formatted_string( result )
|
22
|
+
@engine.heap.it.set_to result
|
23
|
+
else
|
24
|
+
@engine.log.show ''
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Get the Verb's keyword.
|
30
|
+
#
|
31
|
+
def self.keyword
|
32
|
+
return KEYWORD
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Get the Verb's keyword shortcut.
|
37
|
+
#
|
38
|
+
def self.keyword_shortcut
|
39
|
+
return KEYWORD_SHORT
|
40
|
+
end
|
41
|
+
|
42
|
+
# ---------------------------------------------------------------------
|
43
|
+
# Private functions
|
44
|
+
# ---------------------------------------------------------------------
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get the formatted string.
|
50
|
+
#
|
51
|
+
def get_formatted_string( str )
|
52
|
+
if @params&.token_count&.positive?
|
53
|
+
expr = Gloo::Expr::Expression.new( @engine, @params.tokens )
|
54
|
+
val = expr.evaluate
|
55
|
+
color = val.to_sym
|
56
|
+
return @engine.platform.getColorizedString( str, color )
|
57
|
+
end
|
58
|
+
return str
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|