mysh 0.5.6 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mysh/internal/actions/help/env.txt +14 -13
- data/lib/mysh/internal/actions/help/quick.txt +0 -2
- data/lib/mysh/internal/actions/help/sub_help.rb +1 -1
- data/lib/mysh/internal/actions/help/vars.txt +4 -4
- data/lib/mysh/internal/actions/vars.rb +9 -6
- data/lib/mysh/quick.rb +0 -1
- data/lib/mysh/version.rb +1 -1
- data/rakefile.rb +1 -1
- data/tests/my_shell_tests.rb +14 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3dca3a0e863422640812a8eda3d02fac5c1581eb
|
4
|
+
data.tar.gz: e89463ff2e335de7296fa66f25ce2a5265e20c8b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70cd3855b98c7f2fec630dbd6d9981e429b6dcd14ce39f2d8920c75b08c85ff03160c33f3788645d10d2949e942af08bbb045851cf7a85490156f02fcba62a30
|
7
|
+
data.tar.gz: be9ac7a4f9ef4fe2a9c222a2484e097c9d200a80e09b2c494c0b315a28c02354b16b777d2e8c4f9f8e28bb22f0302a85a93f9610400a773f55f4f1c4b40fe3ef
|
@@ -3,18 +3,19 @@ Help: mysh show env command summary:
|
|
3
3
|
The show env (or @env) command is used to display useful information about the
|
4
4
|
current execution environment. This includes:
|
5
5
|
|
6
|
-
user
|
7
|
-
home
|
8
|
-
name
|
9
|
-
shell
|
10
|
-
host
|
11
|
-
os
|
12
|
-
platform
|
13
|
-
java
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
6
|
+
user - The current user name.
|
7
|
+
home - The current home directory.
|
8
|
+
name - The path/name of the mysh program currently executing.
|
9
|
+
shell - The path/name of the system command shell.
|
10
|
+
host - The name of the host computer.
|
11
|
+
os - The current operating system.
|
12
|
+
platform - The operating platform detected by the low-level terminal gem.
|
13
|
+
java - Is the current platform powered by Java?
|
14
|
+
code page - For Windows, what is the current code page?
|
15
|
+
term - What terminal is defined by the system, if one is defined.
|
16
|
+
disp - What display is defined by the system, if one is defined.
|
17
|
+
edit - What editor is defined by the system, if one is defined.
|
18
|
+
PID - The process ID of the mysh program.
|
18
19
|
|
19
|
-
path
|
20
|
+
path - An easy-to-read, formatted version of the current search path.
|
20
21
|
|
@@ -22,7 +22,7 @@ module Mysh
|
|
22
22
|
#Add help topics here. Don't sweat the order; they get sorted by name.
|
23
23
|
# Name Description Help File
|
24
24
|
help = [['', 'General help on mysh.', 'help.txt' ],
|
25
|
-
['
|
25
|
+
['set', 'Help on mysh variables.', 'vars.txt' ],
|
26
26
|
['show', 'Help on the show command.', 'show.txt' ],
|
27
27
|
['@', 'Help on the show command.', 'show.txt' ],
|
28
28
|
['%', 'Help on timed command execution.', 'timed.txt' ],
|
@@ -4,15 +4,15 @@ In mysh, variables are kept that control the behavior of the shell. This simple
|
|
4
4
|
command is used to set, delete, and display these variables. The basic method
|
5
5
|
for setting a variable is:
|
6
6
|
|
7
|
-
$name=value
|
7
|
+
set $name=value
|
8
8
|
|
9
9
|
Where:
|
10
10
|
* name is a word matching the regex: /[a-z][a-z0-9_]*/. Lower case only.
|
11
11
|
* value is a string, with embedded variables and handlebars.
|
12
12
|
|
13
|
-
To erase the value of a variable, use: $$name=
|
14
|
-
To display the name/value of a variable, use: $$name
|
15
|
-
To display all variable names/values use:
|
13
|
+
To erase the value of a variable, use: set $$name=
|
14
|
+
To display the name/value of a variable, use: set $$name
|
15
|
+
To display all variable names/values use: set
|
16
16
|
|
17
17
|
As an escapement, the string $$$$ maps to a single $$.
|
18
18
|
|
@@ -20,8 +20,12 @@ module Mysh
|
|
20
20
|
|
21
21
|
#Execute a command against the internal mysh variables.
|
22
22
|
def process_command(input)
|
23
|
-
match = VAR_EXP.match(input.
|
24
|
-
|
23
|
+
if (match = VAR_EXP.match(input.raw_body))
|
24
|
+
@var_name, @equals, @value = match[:name], match[:equals], match[:value]
|
25
|
+
else
|
26
|
+
@var_name, @equals, @value = nil
|
27
|
+
end
|
28
|
+
|
25
29
|
do_command
|
26
30
|
:internal
|
27
31
|
end
|
@@ -35,7 +39,7 @@ module Mysh
|
|
35
39
|
elsif @equals
|
36
40
|
MNV[sym] = ""
|
37
41
|
elsif @var_name
|
38
|
-
puts "
|
42
|
+
puts "$#{@var_name} = #{MNV.get_source(sym)}"
|
39
43
|
else
|
40
44
|
show_all_values
|
41
45
|
end
|
@@ -52,7 +56,6 @@ module Mysh
|
|
52
56
|
end
|
53
57
|
|
54
58
|
#The show command action object.
|
55
|
-
desc = 'Set/query mysh variables. See
|
56
|
-
|
57
|
-
COMMANDS.add_action(VARS_COMMAND)
|
59
|
+
desc = 'Set/query mysh variables. See ?set for more.'
|
60
|
+
COMMANDS.add_action(VarsCommand.new('set <$name>=value', desc))
|
58
61
|
end
|
data/lib/mysh/quick.rb
CHANGED
@@ -8,7 +8,6 @@ module Mysh
|
|
8
8
|
|
9
9
|
QUICK['!'] = lambda {|input| HISTORY_COMMAND.process_quick_command(input)}
|
10
10
|
QUICK['#'] = lambda {|input| MYSH_COMMENT.process_command(input)}
|
11
|
-
QUICK['$'] = lambda {|input| VARS_COMMAND.process_command(input)}
|
12
11
|
QUICK['%'] = lambda {|input| TIMED_COMMAND.process_command(input)}
|
13
12
|
QUICK['='] = lambda {|input| $mysh_exec_host.execute(input.raw.preprocess)}
|
14
13
|
QUICK['?'] = lambda {|input| HELP_COMMAND.process_quick_command(input)}
|
data/lib/mysh/version.rb
CHANGED
data/rakefile.rb
CHANGED
data/tests/my_shell_tests.rb
CHANGED
@@ -134,60 +134,60 @@ class MyShellTester < Minitest::Test
|
|
134
134
|
assert_equal("", MNV.get_source(:test))
|
135
135
|
refute(MNV.key?(:test), "MNV[:test] should not exist.")
|
136
136
|
|
137
|
-
Mysh.try_execute_command("$test = new value")
|
137
|
+
Mysh.try_execute_command("set $test = new value")
|
138
138
|
assert_equal("new value", MNV[:test])
|
139
139
|
assert_equal("new value", MNV.get_source(:test))
|
140
140
|
assert(MNV.key?(:test), "MNV[:test] should exist.")
|
141
141
|
|
142
|
-
Mysh.try_execute_command("$test =")
|
142
|
+
Mysh.try_execute_command("set $test =")
|
143
143
|
assert_equal("", MNV[:test])
|
144
144
|
assert_equal("", MNV.get_source(:test))
|
145
145
|
refute(MNV.key?(:test), "MNV[:test] should not exist.")
|
146
146
|
|
147
|
-
Mysh.try_execute_command("$test = true")
|
147
|
+
Mysh.try_execute_command("set $test = true")
|
148
148
|
assert(MNV[:test])
|
149
149
|
assert_equal("true", MNV.get_source(:test))
|
150
150
|
assert(MNV.key?(:test), "MNV[:test] should exist.")
|
151
151
|
|
152
|
-
Mysh.try_execute_command("$test = off")
|
152
|
+
Mysh.try_execute_command("set $test = off")
|
153
153
|
assert_equal(false, MNV[:test])
|
154
154
|
assert_equal("off", MNV.get_source(:test))
|
155
155
|
assert(MNV.key?(:test), "MNV[:test] should exist.")
|
156
156
|
|
157
|
-
Mysh.try_execute_command("$a = foo")
|
158
|
-
Mysh.try_execute_command("$b = bar")
|
159
|
-
Mysh.try_execute_command("$test = $a$b")
|
157
|
+
Mysh.try_execute_command("set $a = foo")
|
158
|
+
Mysh.try_execute_command("set $b = bar")
|
159
|
+
Mysh.try_execute_command("set $test = $a$b")
|
160
160
|
assert_equal("foobar", MNV[:test])
|
161
161
|
assert_equal("$a$b", MNV.get_source(:test))
|
162
162
|
|
163
|
-
Mysh.try_execute_command("$test = $$foo")
|
163
|
+
Mysh.try_execute_command("set $test = $$foo")
|
164
164
|
assert_equal("$foo", MNV[:test])
|
165
165
|
assert_equal("$$foo", MNV.get_source(:test))
|
166
166
|
|
167
|
-
Mysh.try_execute_command("$bad = $bad")
|
167
|
+
Mysh.try_execute_command("set $bad = $bad")
|
168
168
|
assert_raises { MNV[:bad] }
|
169
169
|
|
170
170
|
MNV[:test] = "{{(1..9).to_a.join}}"
|
171
171
|
assert_equal("123456789", MNV[:test])
|
172
172
|
assert_equal("{{(1..9).to_a.join}}", MNV.get_source(:test))
|
173
173
|
|
174
|
-
Mysh.try_execute_command("$test = $whats_all_this")
|
174
|
+
Mysh.try_execute_command("set $test = $whats_all_this")
|
175
175
|
assert_equal("$whats_all_this", MNV[:test])
|
176
176
|
assert_equal("$whats_all_this", MNV.get_source(:test))
|
177
177
|
|
178
|
-
Mysh.try_execute_command("$bad = {{ MNV[:bad] }}")
|
178
|
+
Mysh.try_execute_command("set $bad = {{ MNV[:bad] }}")
|
179
179
|
assert_raises { MNV[:bad] }
|
180
180
|
assert_raises { MNV[:bad] } #Yes test this twice!
|
181
181
|
assert_raises { Mysh.try_execute_command("=$bad") }
|
182
182
|
assert_raises { Mysh.try_execute_command("=$bad") } #And this too!
|
183
183
|
|
184
|
-
Mysh.try_execute_command("$bad = OK")
|
184
|
+
Mysh.try_execute_command("set $bad = OK")
|
185
185
|
assert_equal("OK", MNV[:bad])
|
186
186
|
assert_equal("OK", MNV[:bad]) #And this too!
|
187
187
|
end
|
188
188
|
|
189
189
|
def test_executing_some_strings
|
190
|
-
Mysh.process_string("$c=43\
|
190
|
+
Mysh.process_string("set $c=43\nset $d=99")
|
191
191
|
assert_equal("43", MNV[:c])
|
192
192
|
assert_equal("99", MNV[:d])
|
193
193
|
end
|
@@ -214,7 +214,7 @@ class MyShellTester < Minitest::Test
|
|
214
214
|
assert_equal(["@", "last", "45", "is finished", "4", "ever"], wrapper.parsed)
|
215
215
|
assert_equal(["last", "45", "is finished", "4", "ever"], wrapper.args)
|
216
216
|
|
217
|
-
Mysh.process_string("$unjust = him")
|
217
|
+
Mysh.process_string("set $unjust = him")
|
218
218
|
wrapper = Mysh::InputWrapper.new "Lock $unjust up!"
|
219
219
|
|
220
220
|
assert_equal("Lock $unjust up!", wrapper.raw)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-09-
|
11
|
+
date: 2018-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|