gloo-lang 0.9.3 → 0.9.6
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/info.rb +34 -0
- 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 +23 -21
- 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/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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42b1ca8c03074ae64ac797bfcdc72b17479cabead579fb94dd8232cbeef3fc6a
|
4
|
+
data.tar.gz: 34c0a1d8d4aabfd76f8d34d170de91760030ce15f49cdbceacad202cd43dfa55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8578816796520b92afdc8671fd914d2612dd5a512b6cc03bff9602ea3f9851902fe61753a59c58526e2aedafbe4f00eb6647c25df49cfbbf046d4c02545ad5b8
|
7
|
+
data.tar.gz: 132b981e50798bfdada690d892ddb67677d001036b08faa058c705317bf995006c2d40e022ca79269d45610e0535f9b0f2422f77f6b48b79b03c04f95ec67958
|
data/Gemfile.lock
CHANGED
data/gloo-lang.gemspec
CHANGED
@@ -32,6 +32,7 @@ Gem::Specification.new do |spec|
|
|
32
32
|
spec.add_dependency 'json', '~> 2.1', '>= 2.1.0'
|
33
33
|
spec.add_dependency 'openssl', '~> 2.1', '>= 2.1.0'
|
34
34
|
spec.add_dependency 'net-ssh', '~> 6.1', '>= 6.1.0'
|
35
|
+
spec.add_dependency 'tty-platform', '~> 0.3', '>= 0.3.0'
|
35
36
|
# spec.add_dependency 'mysql2', '~> 0.5', '>= 0.5.3'
|
36
37
|
# spec.add_dependency 'sqlite3', '~> 1.4', '>= 1.4.2'
|
37
38
|
end
|
data/lib/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.6
|
data/lib/gloo_lang/app/args.rb
CHANGED
data/lib/gloo_lang/app/engine.rb
CHANGED
@@ -7,15 +7,11 @@
|
|
7
7
|
# to the relevant element.
|
8
8
|
#
|
9
9
|
|
10
|
-
require 'tty-prompt'
|
11
|
-
require 'tty-cursor'
|
12
|
-
require 'colorize'
|
13
|
-
|
14
10
|
module GlooLang
|
15
11
|
module App
|
16
12
|
class Engine
|
17
13
|
|
18
|
-
attr_reader :args, :mode, :running,
|
14
|
+
attr_reader :args, :mode, :running, :platform,
|
19
15
|
:dictionary, :parser, :heap, :factory
|
20
16
|
attr_accessor :last_cmd, :persist_man, :event_manager,
|
21
17
|
:exec_env, :help, :converter
|
@@ -23,12 +19,15 @@ module GlooLang
|
|
23
19
|
#
|
24
20
|
# Set up the engine with basic elements.
|
25
21
|
#
|
26
|
-
def initialize( params = [] )
|
22
|
+
def initialize( params = [], platform=nil, log=nil )
|
27
23
|
$engine = self
|
28
24
|
@args = Args.new( params )
|
29
25
|
$settings = Settings.new( ENV[ 'GLOO_ENV' ] )
|
30
|
-
|
31
|
-
$
|
26
|
+
|
27
|
+
$log = log ? log : Log.new
|
28
|
+
$log.quiet = @args.quiet?
|
29
|
+
|
30
|
+
@platform = platform ? platform : Platform.new
|
32
31
|
$log.debug 'engine intialized...'
|
33
32
|
end
|
34
33
|
|
@@ -113,23 +112,6 @@ module GlooLang
|
|
113
112
|
@persist_man.load( name ) if name
|
114
113
|
end
|
115
114
|
|
116
|
-
#
|
117
|
-
# Prompt for the next command.
|
118
|
-
#
|
119
|
-
def prompt_cmd
|
120
|
-
@last_cmd = $prompt.ask( default_prompt )
|
121
|
-
end
|
122
|
-
|
123
|
-
#
|
124
|
-
# Get the default prompt text.
|
125
|
-
#
|
126
|
-
def default_prompt
|
127
|
-
dt = DateTime.now
|
128
|
-
d = dt.strftime( '%Y.%m.%d' )
|
129
|
-
t = dt.strftime( '%I:%M:%S' )
|
130
|
-
return "#{'gloo'.blue} #{d.yellow} #{t.white} >"
|
131
|
-
end
|
132
|
-
|
133
115
|
#
|
134
116
|
# Is the last command entered blank?
|
135
117
|
#
|
@@ -145,7 +127,7 @@ module GlooLang
|
|
145
127
|
#
|
146
128
|
def loop
|
147
129
|
while @running
|
148
|
-
prompt_cmd
|
130
|
+
@last_cmd = @platform.prompt_cmd
|
149
131
|
process_cmd
|
150
132
|
end
|
151
133
|
end
|
@@ -155,7 +137,7 @@ module GlooLang
|
|
155
137
|
#
|
156
138
|
def process_cmd
|
157
139
|
if last_cmd_blank?
|
158
|
-
clear_screen
|
140
|
+
@platform.clear_screen
|
159
141
|
return
|
160
142
|
end
|
161
143
|
|
@@ -184,7 +166,7 @@ module GlooLang
|
|
184
166
|
# Show the version information and then quit.
|
185
167
|
#
|
186
168
|
def run_version
|
187
|
-
|
169
|
+
@platform.show Info.display_title unless @args.quiet?
|
188
170
|
quit
|
189
171
|
end
|
190
172
|
|
@@ -196,15 +178,6 @@ module GlooLang
|
|
196
178
|
quit
|
197
179
|
end
|
198
180
|
|
199
|
-
#
|
200
|
-
# Clear the screen.
|
201
|
-
#
|
202
|
-
def clear_screen
|
203
|
-
@cursor ||= TTY::Cursor
|
204
|
-
print @cursor.clear_screen
|
205
|
-
print @cursor.move_to( 0, 0 )
|
206
|
-
end
|
207
|
-
|
208
181
|
# ---------------------------------------------------------------------
|
209
182
|
# Error Handling
|
210
183
|
# ---------------------------------------------------------------------
|
data/lib/gloo_lang/app/help.rb
CHANGED
@@ -4,9 +4,6 @@
|
|
4
4
|
# Help system.
|
5
5
|
#
|
6
6
|
|
7
|
-
require 'tty-markdown'
|
8
|
-
require 'tty-pager'
|
9
|
-
|
10
7
|
module GlooLang
|
11
8
|
module App
|
12
9
|
class Help
|
@@ -61,11 +58,7 @@ module GlooLang
|
|
61
58
|
|
62
59
|
data = self.get_topic_data( topic )
|
63
60
|
page = data.lines.count > Settings.page_size
|
64
|
-
|
65
|
-
show_markdown_data( data, page )
|
66
|
-
else
|
67
|
-
show_text_data( data, page )
|
68
|
-
end
|
61
|
+
$engine.platform.show( data, topic_is_md?( topic ), page )
|
69
62
|
end
|
70
63
|
|
71
64
|
#
|
@@ -75,39 +68,7 @@ module GlooLang
|
|
75
68
|
return if $engine.args.quiet?
|
76
69
|
|
77
70
|
data = self.get_topic_data( topic )
|
78
|
-
|
79
|
-
show_markdown_data data
|
80
|
-
else
|
81
|
-
show_text_data data
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
#
|
86
|
-
# Show the markdown data.
|
87
|
-
#
|
88
|
-
def show_text_data( data, page = false )
|
89
|
-
if page
|
90
|
-
pager = TTY::Pager.new
|
91
|
-
pager.page( data )
|
92
|
-
else
|
93
|
-
puts data.white
|
94
|
-
puts
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
#
|
99
|
-
# Show the markdown data.
|
100
|
-
#
|
101
|
-
def show_markdown_data( data, page = false )
|
102
|
-
md = TTY::Markdown.parse data
|
103
|
-
|
104
|
-
if page
|
105
|
-
pager = TTY::Pager.new
|
106
|
-
pager.page( md )
|
107
|
-
else
|
108
|
-
puts md
|
109
|
-
puts
|
110
|
-
end
|
71
|
+
$engine.platform.show( data, topic_is_md?( topic ), false )
|
111
72
|
end
|
112
73
|
|
113
74
|
#
|
data/lib/gloo_lang/app/info.rb
CHANGED
@@ -8,6 +8,14 @@ module GlooLang
|
|
8
8
|
module App
|
9
9
|
class Info
|
10
10
|
|
11
|
+
#
|
12
|
+
# Register other Info classes when they are loaded.
|
13
|
+
#
|
14
|
+
def self.inherited( subclass )
|
15
|
+
$infos = [] unless $infos
|
16
|
+
$infos << subclass
|
17
|
+
end
|
18
|
+
|
11
19
|
#
|
12
20
|
# Load the version from the VERSION file.
|
13
21
|
#
|
@@ -28,6 +36,32 @@ module GlooLang
|
|
28
36
|
return "#{APP_NAME}, version #{VERSION}"
|
29
37
|
end
|
30
38
|
|
39
|
+
#
|
40
|
+
# Get the full application version information,
|
41
|
+
# including engine version.
|
42
|
+
#
|
43
|
+
def self.full_version
|
44
|
+
str = "#{display_title}"
|
45
|
+
if $infos
|
46
|
+
$infos.each do |o|
|
47
|
+
str << "\n#{o.display_title}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return str
|
51
|
+
end
|
52
|
+
|
31
53
|
end
|
54
|
+
|
55
|
+
#
|
56
|
+
# Add the ruby version information.
|
57
|
+
#
|
58
|
+
class RubyInfo < Info
|
59
|
+
|
60
|
+
def self.display_title
|
61
|
+
return "Ruby version: #{RUBY_VERSION}"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
32
66
|
end
|
33
67
|
end
|
data/lib/gloo_lang/app/log.rb
CHANGED
@@ -4,25 +4,23 @@
|
|
4
4
|
# Application Logging wrapper.
|
5
5
|
#
|
6
6
|
require 'active_support'
|
7
|
-
require 'colorize'
|
8
|
-
require 'colorized_string'
|
9
7
|
|
10
8
|
module GlooLang
|
11
9
|
module App
|
12
10
|
class Log
|
13
11
|
|
14
|
-
attr_reader :logger
|
12
|
+
attr_reader :logger
|
13
|
+
attr_accessor :quiet
|
15
14
|
|
16
15
|
#
|
17
16
|
# Set up a logger.
|
18
17
|
# If quiet is true, then message are written to the log
|
19
18
|
# but not to the console.
|
20
19
|
#
|
21
|
-
def initialize( quiet )
|
20
|
+
def initialize( quiet=true )
|
22
21
|
f = File.join( $settings.log_path, 'gloo.log' )
|
23
22
|
@logger = Logger.new( f )
|
24
23
|
@logger.level = Logger::DEBUG
|
25
|
-
@quiet = quiet
|
26
24
|
end
|
27
25
|
|
28
26
|
#
|
@@ -45,7 +43,7 @@ module GlooLang
|
|
45
43
|
#
|
46
44
|
def info( msg )
|
47
45
|
@logger.info msg
|
48
|
-
puts msg
|
46
|
+
puts msg unless @quiet
|
49
47
|
end
|
50
48
|
|
51
49
|
#
|
@@ -54,7 +52,7 @@ module GlooLang
|
|
54
52
|
#
|
55
53
|
def warn( msg )
|
56
54
|
@logger.warn msg
|
57
|
-
puts msg
|
55
|
+
puts msg unless @quiet
|
58
56
|
end
|
59
57
|
|
60
58
|
#
|
@@ -68,11 +66,11 @@ module GlooLang
|
|
68
66
|
if ex
|
69
67
|
@logger.error ex.message
|
70
68
|
@logger.error ex.backtrace
|
71
|
-
puts msg
|
72
|
-
puts ex.message
|
69
|
+
puts msg unless @quiet
|
70
|
+
puts ex.message unless @quiet
|
73
71
|
puts ex.backtrace unless @quiet
|
74
72
|
else
|
75
|
-
puts msg
|
73
|
+
puts msg unless @quiet
|
76
74
|
end
|
77
75
|
end
|
78
76
|
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# Author:: Eric Crane (mailto:eric.crane@mac.com)
|
2
|
+
# Copyright:: Copyright (c) 2022 Eric Crane. All rights reserved.
|
3
|
+
#
|
4
|
+
# Handle input and output for the current platform.
|
5
|
+
#
|
6
|
+
# This is an abstract base class and minimal implementation
|
7
|
+
# is only to facilitate testing.
|
8
|
+
#
|
9
|
+
|
10
|
+
module GlooLang
|
11
|
+
module App
|
12
|
+
class Platform
|
13
|
+
|
14
|
+
#
|
15
|
+
# Set up Platform.
|
16
|
+
#
|
17
|
+
def initialize
|
18
|
+
end
|
19
|
+
|
20
|
+
#
|
21
|
+
# Show a message.
|
22
|
+
# Abstract--implment in subclass.
|
23
|
+
#
|
24
|
+
def show( msg, md=false, page=false )
|
25
|
+
puts msg
|
26
|
+
end
|
27
|
+
|
28
|
+
#
|
29
|
+
# Prompt for the next command.
|
30
|
+
# Abstract--implment in subclass.
|
31
|
+
#
|
32
|
+
def prompt_cmd
|
33
|
+
return ''
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# Clear the screen.
|
38
|
+
# Abstract--implment in subclass.
|
39
|
+
#
|
40
|
+
def clear_screen
|
41
|
+
end
|
42
|
+
|
43
|
+
#
|
44
|
+
# Edit some temporary text and return the edited text.
|
45
|
+
# Abstract--implment in subclass.
|
46
|
+
#
|
47
|
+
def edit initial_value
|
48
|
+
return initial_value
|
49
|
+
end
|
50
|
+
|
51
|
+
#
|
52
|
+
# Show the given table data.
|
53
|
+
# Abstract--implment in subclass.
|
54
|
+
#
|
55
|
+
def show_table( headers, data, title = nil )
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# Get the number of vertical lines on screen.
|
60
|
+
# Abstract--implment in subclass.
|
61
|
+
#
|
62
|
+
def lines
|
63
|
+
return 40
|
64
|
+
end
|
65
|
+
|
66
|
+
#
|
67
|
+
# Get the number of horizontal columns on screen.
|
68
|
+
# Abstract--implment in subclass.
|
69
|
+
#
|
70
|
+
def cols
|
71
|
+
return 80
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -5,8 +5,6 @@
|
|
5
5
|
#
|
6
6
|
|
7
7
|
require 'yaml'
|
8
|
-
require 'tty-screen'
|
9
|
-
require 'colorize'
|
10
8
|
|
11
9
|
module GlooLang
|
12
10
|
module App
|
@@ -48,11 +46,11 @@ module GlooLang
|
|
48
46
|
# Can be seen in app with 'help settings'
|
49
47
|
#
|
50
48
|
def show
|
51
|
-
puts "\nApplication Settings:"
|
52
|
-
puts ' Startup with: '
|
53
|
-
puts ' Indent in Listing: '
|
54
|
-
puts ' Screen Lines: '
|
55
|
-
puts ' Page Size: '
|
49
|
+
puts "\nApplication Settings:"
|
50
|
+
puts ' Startup with: ' + @start_with
|
51
|
+
puts ' Indent in Listing: ' + @list_indent.to_s
|
52
|
+
puts ' Screen Lines: ' + GlooLang::App::Settings.lines.to_s
|
53
|
+
puts ' Page Size: ' + GlooLang::App::Settings.page_size.to_s
|
56
54
|
puts ''
|
57
55
|
self.show_paths
|
58
56
|
puts ''
|
@@ -62,24 +60,49 @@ module GlooLang
|
|
62
60
|
# Show path settings
|
63
61
|
#
|
64
62
|
def show_paths
|
65
|
-
puts ' User Root Path is here: '
|
66
|
-
puts ' Projects Path: '
|
67
|
-
puts ' Tmp Path: '
|
68
|
-
puts ' Debug Path: '
|
63
|
+
puts ' User Root Path is here: ' + @user_root
|
64
|
+
puts ' Projects Path: ' + @project_path
|
65
|
+
puts ' Tmp Path: ' + @tmp_path
|
66
|
+
puts ' Debug Path: ' + @debug_path
|
69
67
|
end
|
70
68
|
|
69
|
+
# #
|
70
|
+
# # Show the current application settings.
|
71
|
+
# # Can be seen in app with 'help settings'
|
72
|
+
# #
|
73
|
+
# def show
|
74
|
+
# puts "\nApplication Settings:".blue
|
75
|
+
# puts ' Startup with: '.yellow + @start_with.white
|
76
|
+
# puts ' Indent in Listing: '.yellow + @list_indent.to_s.white
|
77
|
+
# puts ' Screen Lines: '.yellow + GlooLang::App::Settings.lines.to_s.white
|
78
|
+
# puts ' Page Size: '.yellow + GlooLang::App::Settings.page_size.to_s.white
|
79
|
+
# puts ''
|
80
|
+
# self.show_paths
|
81
|
+
# puts ''
|
82
|
+
# end
|
83
|
+
#
|
84
|
+
# #
|
85
|
+
# # Show path settings
|
86
|
+
# #
|
87
|
+
# def show_paths
|
88
|
+
# puts ' User Root Path is here: '.yellow + @user_root.white
|
89
|
+
# puts ' Projects Path: '.yellow + @project_path.white
|
90
|
+
# puts ' Tmp Path: '.yellow + @tmp_path.white
|
91
|
+
# puts ' Debug Path: '.yellow + @debug_path.white
|
92
|
+
# end
|
93
|
+
|
71
94
|
#
|
72
95
|
# Get the number of vertical lines on screen.
|
73
96
|
#
|
74
97
|
def self.lines
|
75
|
-
|
98
|
+
$engine.platform.lines
|
76
99
|
end
|
77
100
|
|
78
101
|
#
|
79
102
|
# Get the number of horizontal columns on screen.
|
80
103
|
#
|
81
104
|
def self.cols
|
82
|
-
|
105
|
+
$engine.platform.cols
|
83
106
|
end
|
84
107
|
|
85
108
|
#
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# An object that contains a collection of other objects.
|
5
5
|
#
|
6
|
-
require 'tty-table'
|
7
|
-
require 'pastel'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -59,16 +57,7 @@ module GlooLang
|
|
59
57
|
#
|
60
58
|
def msg_show_key_value_table
|
61
59
|
data = self.children.map { |o| [ o.name, o.value ] }
|
62
|
-
|
63
|
-
table = TTY::Table.new rows: data
|
64
|
-
pad = [ 0, 1, 0, 1 ]
|
65
|
-
rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
|
66
|
-
r.border.style = :blue
|
67
|
-
r.filter = proc do |val, _row_index, col_index|
|
68
|
-
col_index.zero? ? pastel.blue( val ) : pastel.white( val )
|
69
|
-
end
|
70
|
-
end
|
71
|
-
puts "\n #{rendered}\n\n"
|
60
|
+
$engine.platform.show_table nil, data, title
|
72
61
|
end
|
73
62
|
|
74
63
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# A [multiline] block of text.
|
5
5
|
#
|
6
|
-
require 'tty-editor'
|
7
|
-
require 'tty-pager'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -12,7 +10,6 @@ module GlooLang
|
|
12
10
|
|
13
11
|
KEYWORD = 'text'.freeze
|
14
12
|
KEYWORD_SHORT = 'txt'.freeze
|
15
|
-
DEFAULT_TMP_FILE = 'tmp.txt'.freeze
|
16
13
|
|
17
14
|
#
|
18
15
|
# The name of the object type.
|
@@ -67,19 +64,14 @@ module GlooLang
|
|
67
64
|
def msg_page
|
68
65
|
return unless value
|
69
66
|
|
70
|
-
|
71
|
-
pager = TTY::Pager.new
|
72
|
-
pager.page( value )
|
67
|
+
$engine.platform.show( value, false, true )
|
73
68
|
end
|
74
69
|
|
75
70
|
#
|
76
71
|
# Edit the text in the default editor.
|
77
72
|
#
|
78
73
|
def msg_edit
|
79
|
-
|
80
|
-
File.open( tmp, 'w' ) { |file| file.write( self.value ) }
|
81
|
-
TTY::Editor.open( tmp )
|
82
|
-
set_value File.read( tmp )
|
74
|
+
self.value = $engine.platform.edit( self.value )
|
83
75
|
end
|
84
76
|
|
85
77
|
end
|
@@ -3,8 +3,6 @@
|
|
3
3
|
#
|
4
4
|
# Markdown data.
|
5
5
|
#
|
6
|
-
require 'tty-markdown'
|
7
|
-
require 'tty-pager'
|
8
6
|
|
9
7
|
module GlooLang
|
10
8
|
module Objs
|
@@ -64,7 +62,7 @@ module GlooLang
|
|
64
62
|
# Show the markdown data in the terminal.
|
65
63
|
#
|
66
64
|
def msg_show
|
67
|
-
|
65
|
+
$engine.platform.show( self.value, true, false )
|
68
66
|
end
|
69
67
|
|
70
68
|
#
|
@@ -73,10 +71,7 @@ module GlooLang
|
|
73
71
|
def msg_page
|
74
72
|
return unless self.value
|
75
73
|
|
76
|
-
md
|
77
|
-
# pager = TTY::Pager::SystemPager.new command: 'less -R'
|
78
|
-
pager = TTY::Pager.new
|
79
|
-
pager.page( md )
|
74
|
+
$engine.platform.show( md, true, true )
|
80
75
|
end
|
81
76
|
|
82
77
|
end
|
@@ -4,8 +4,6 @@
|
|
4
4
|
# A data table.
|
5
5
|
# The table container headers and data.
|
6
6
|
#
|
7
|
-
require 'tty-table'
|
8
|
-
require 'pastel'
|
9
7
|
|
10
8
|
module GlooLang
|
11
9
|
module Objs
|
@@ -106,33 +104,7 @@ module GlooLang
|
|
106
104
|
#
|
107
105
|
def msg_show
|
108
106
|
title = self.value
|
109
|
-
|
110
|
-
end
|
111
|
-
|
112
|
-
# ---------------------------------------------------------------------
|
113
|
-
# Static table helper
|
114
|
-
# ---------------------------------------------------------------------
|
115
|
-
|
116
|
-
#
|
117
|
-
# Show the given table data.
|
118
|
-
#
|
119
|
-
def self.show( headers, data, title = nil )
|
120
|
-
pastel = ::Pastel.new
|
121
|
-
table = TTY::Table.new headers, data
|
122
|
-
pad = [ 0, 1, 0, 1 ]
|
123
|
-
rendered = table.render( :ascii, indent: 2, padding: pad ) do |r|
|
124
|
-
r.border.style = :blue
|
125
|
-
r.filter = proc do |val, row_index, _col_index|
|
126
|
-
# col_index % 2 == 1 ? pastel.red.on_green(val) : val
|
127
|
-
if row_index.zero?
|
128
|
-
pastel.blue( val )
|
129
|
-
else
|
130
|
-
row_index.odd? ? pastel.white( val ) : pastel.yellow( val )
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
puts "\n#{title.white}"
|
135
|
-
puts "#{rendered}\n\n"
|
107
|
+
$engine.platform.show_table headers, data, title
|
136
108
|
end
|
137
109
|
|
138
110
|
end
|
data/lib/gloo_lang/verbs/show.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
# Show a single object's value.
|
5
5
|
#
|
6
|
-
require 'colorized_string'
|
6
|
+
# require 'colorized_string'
|
7
7
|
|
8
8
|
module GlooLang
|
9
9
|
module Verbs
|
@@ -54,7 +54,8 @@ module GlooLang
|
|
54
54
|
expr = GlooLang::Expr::Expression.new( @params.tokens )
|
55
55
|
val = expr.evaluate
|
56
56
|
color = val.to_sym
|
57
|
-
return ColorizedString[ str.to_s ].colorize( color )
|
57
|
+
# return ColorizedString[ str.to_s ].colorize( color )
|
58
|
+
return str.to_s
|
58
59
|
end
|
59
60
|
return str
|
60
61
|
end
|