gloo-lang 0.9.4 → 0.9.7
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/gloo-lang.gemspec +1 -0
- data/lib/VERSION +1 -1
- data/lib/gloo_lang/app/args.rb +0 -1
- data/lib/gloo_lang/app/engine.rb +10 -37
- data/lib/gloo_lang/app/help.rb +2 -41
- data/lib/gloo_lang/app/log.rb +8 -10
- data/lib/gloo_lang/app/platform.rb +75 -0
- data/lib/gloo_lang/app/settings.rb +36 -13
- data/lib/gloo_lang/objs/basic/container.rb +1 -12
- data/lib/gloo_lang/objs/basic/text.rb +2 -10
- data/lib/gloo_lang/objs/data/markdown.rb +2 -7
- data/lib/gloo_lang/objs/data/table.rb +1 -29
- data/lib/gloo_lang/verbs/show.rb +3 -2
- metadata +22 -22
- data/lib/gloo_lang/objs/cli/banner.rb +0 -108
- data/lib/gloo_lang/objs/cli/bar.rb +0 -133
- data/lib/gloo_lang/objs/cli/colorize.rb +0 -73
- data/lib/gloo_lang/objs/cli/confirm.rb +0 -96
- data/lib/gloo_lang/objs/cli/menu.rb +0 -206
- data/lib/gloo_lang/objs/cli/menu_item.rb +0 -95
- data/lib/gloo_lang/objs/cli/pastel.rb +0 -97
- data/lib/gloo_lang/objs/cli/prompt.rb +0 -110
- data/lib/gloo_lang/objs/cli/select.rb +0 -126
- data/lib/gloo_lang/objs/data/mysql.rb +0 -192
- data/lib/gloo_lang/objs/data/sqlite.rb +0 -159
- data/lib/gloo_lang/objs/dev/git.rb +0 -140
- data/lib/gloo_lang/objs/dev/stats.rb +0 -120
- data/lib/gloo_lang/objs/snd/play.rb +0 -48
- data/lib/gloo_lang/objs/snd/say.rb +0 -98
- data/lib/gloo_lang/objs/system/file_handle.rb +0 -138
- data/lib/gloo_lang/objs/system/ssh_exec.rb +0 -126
- data/lib/gloo_lang/objs/system/system.rb +0 -136
- data/lib/gloo_lang/verbs/alert.rb +0 -79
- data/lib/gloo_lang/verbs/beep.rb +0 -40
- data/lib/gloo_lang/verbs/cls.rb +0 -37
@@ -1,136 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# An object that can make a system call.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Objs
|
9
|
-
class System < GlooLang::Core::Obj
|
10
|
-
|
11
|
-
KEYWORD = 'system'.freeze
|
12
|
-
KEYWORD_SHORT = 'sys'.freeze
|
13
|
-
CMD = 'command'.freeze
|
14
|
-
DEFAULT_CMD = 'date'.freeze
|
15
|
-
RESULT = 'result'.freeze
|
16
|
-
GET_OUTPUT = 'get_output'.freeze
|
17
|
-
|
18
|
-
#
|
19
|
-
# The name of the object type.
|
20
|
-
#
|
21
|
-
def self.typename
|
22
|
-
return KEYWORD
|
23
|
-
end
|
24
|
-
|
25
|
-
#
|
26
|
-
# The short name of the object type.
|
27
|
-
#
|
28
|
-
def self.short_typename
|
29
|
-
return KEYWORD_SHORT
|
30
|
-
end
|
31
|
-
|
32
|
-
#
|
33
|
-
# Get the URI from the child object.
|
34
|
-
# Returns nil if there is none.
|
35
|
-
#
|
36
|
-
def cmd_value
|
37
|
-
cmd = find_child CMD
|
38
|
-
return nil unless cmd
|
39
|
-
|
40
|
-
return cmd.value
|
41
|
-
end
|
42
|
-
|
43
|
-
#
|
44
|
-
# Set the result of the system call.
|
45
|
-
#
|
46
|
-
def set_result( data )
|
47
|
-
r = find_child RESULT
|
48
|
-
return nil unless r
|
49
|
-
|
50
|
-
r.set_value data
|
51
|
-
end
|
52
|
-
|
53
|
-
#
|
54
|
-
# Should the system call get output?
|
55
|
-
# If so, the system call will run and get output,
|
56
|
-
# otherwise it will just get the result of the call.
|
57
|
-
#
|
58
|
-
def output?
|
59
|
-
o = find_child GET_OUTPUT
|
60
|
-
return false unless o
|
61
|
-
|
62
|
-
return o.value
|
63
|
-
end
|
64
|
-
|
65
|
-
# ---------------------------------------------------------------------
|
66
|
-
# Children
|
67
|
-
# ---------------------------------------------------------------------
|
68
|
-
|
69
|
-
#
|
70
|
-
# Does this object have children to add when an object
|
71
|
-
# is created in interactive mode?
|
72
|
-
# This does not apply during obj load, etc.
|
73
|
-
#
|
74
|
-
def add_children_on_create?
|
75
|
-
return true
|
76
|
-
end
|
77
|
-
|
78
|
-
#
|
79
|
-
# Add children to this object.
|
80
|
-
# This is used by containers to add children needed
|
81
|
-
# for default configurations.
|
82
|
-
#
|
83
|
-
def add_default_children
|
84
|
-
fac = $engine.factory
|
85
|
-
fac.create_string CMD, DEFAULT_CMD, self
|
86
|
-
fac.create_bool GET_OUTPUT, true, self
|
87
|
-
fac.create_string RESULT, nil, self
|
88
|
-
end
|
89
|
-
|
90
|
-
# ---------------------------------------------------------------------
|
91
|
-
# Messages
|
92
|
-
# ---------------------------------------------------------------------
|
93
|
-
|
94
|
-
#
|
95
|
-
# Get a list of message names that this object receives.
|
96
|
-
#
|
97
|
-
def self.messages
|
98
|
-
return super + [ 'run' ]
|
99
|
-
end
|
100
|
-
|
101
|
-
#
|
102
|
-
# Run the system command.
|
103
|
-
#
|
104
|
-
def msg_run
|
105
|
-
if output?
|
106
|
-
run_with_output
|
107
|
-
else
|
108
|
-
run_with_result
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
#
|
113
|
-
# Run the command and collect output.
|
114
|
-
#
|
115
|
-
def run_with_output
|
116
|
-
cmd = cmd_value
|
117
|
-
return unless cmd
|
118
|
-
|
119
|
-
result = `#{cmd}`
|
120
|
-
set_result result
|
121
|
-
end
|
122
|
-
|
123
|
-
#
|
124
|
-
# Run the command and set the result.
|
125
|
-
#
|
126
|
-
def run_with_result
|
127
|
-
cmd = cmd_value
|
128
|
-
return unless cmd
|
129
|
-
|
130
|
-
result = system cmd
|
131
|
-
set_result result
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2019 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Show a system notification.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Verbs
|
9
|
-
class Alert < GlooLang::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'alert'.freeze
|
12
|
-
KEYWORD_SHORT = '!'.freeze
|
13
|
-
|
14
|
-
MISSING_EXPR_ERR = 'Missing Expression!'.freeze
|
15
|
-
NO_RESULT_ERR = 'Expression evaluated with no result!'.freeze
|
16
|
-
|
17
|
-
#
|
18
|
-
# Run the verb.
|
19
|
-
#
|
20
|
-
def run
|
21
|
-
unless @tokens.token_count > 1
|
22
|
-
$engine.err MISSING_EXPR_ERR
|
23
|
-
return
|
24
|
-
end
|
25
|
-
|
26
|
-
expr = GlooLang::Expr::Expression.new( @tokens.params )
|
27
|
-
result = expr.evaluate
|
28
|
-
|
29
|
-
if result
|
30
|
-
$engine.heap.it.set_to result
|
31
|
-
post_alert result
|
32
|
-
else
|
33
|
-
$engine.err NO_RESULT_ERR
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
#
|
38
|
-
# Get the Verb's keyword.
|
39
|
-
#
|
40
|
-
def self.keyword
|
41
|
-
return KEYWORD
|
42
|
-
end
|
43
|
-
|
44
|
-
#
|
45
|
-
# Get the Verb's keyword shortcut.
|
46
|
-
#
|
47
|
-
def self.keyword_shortcut
|
48
|
-
return KEYWORD_SHORT
|
49
|
-
end
|
50
|
-
|
51
|
-
# ---------------------------------------------------------------------
|
52
|
-
# Private functions
|
53
|
-
# ---------------------------------------------------------------------
|
54
|
-
|
55
|
-
private
|
56
|
-
|
57
|
-
#
|
58
|
-
# Post the alert for the specific platform.
|
59
|
-
# Notice is not posted if we're in quiet mode.
|
60
|
-
#
|
61
|
-
def post_alert( msg )
|
62
|
-
$log.info msg
|
63
|
-
return if $engine.args.quiet?
|
64
|
-
|
65
|
-
post_osx msg
|
66
|
-
end
|
67
|
-
|
68
|
-
#
|
69
|
-
# Post the alert on the Mac OSX.
|
70
|
-
#
|
71
|
-
def post_osx( msg )
|
72
|
-
cmd1 = '/usr/bin/osascript -e "display notification \"'
|
73
|
-
cmd2 = '\" with title \"Gloo\" "'
|
74
|
-
system( cmd1 + msg.to_s + cmd2 )
|
75
|
-
end
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
data/lib/gloo_lang/verbs/beep.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Play a standard system beep sound.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Verbs
|
9
|
-
class Beep < GlooLang::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'beep'.freeze
|
12
|
-
KEYWORD_SHORT = 'b'.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
|
-
print 7.chr
|
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
|
data/lib/gloo_lang/verbs/cls.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
-
# Copyright:: Copyright (c) 2020 Eric Crane. All rights reserved.
|
3
|
-
#
|
4
|
-
# Clear the screen.
|
5
|
-
#
|
6
|
-
|
7
|
-
module GlooLang
|
8
|
-
module Verbs
|
9
|
-
class Cls < GlooLang::Core::Verb
|
10
|
-
|
11
|
-
KEYWORD = 'cls'.freeze
|
12
|
-
KEYWORD_SHORT = 'cls'.freeze
|
13
|
-
|
14
|
-
#
|
15
|
-
# Run the verb.
|
16
|
-
#
|
17
|
-
def run
|
18
|
-
$engine&.clear_screen
|
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
|