mysh 0.1.13 → 0.1.14
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/README.md +36 -41
- data/lib/mysh.rb +3 -3
- data/lib/mysh/commands/cd.rb +5 -5
- data/lib/mysh/commands/command_path.rb +1 -1
- data/lib/mysh/commands/exit.rb +3 -3
- data/lib/mysh/commands/help.rb +28 -9
- data/lib/mysh/commands/help.txt +6 -2
- data/lib/mysh/commands/{help_ruby.txt → help_expr.txt} +1 -1
- data/lib/mysh/commands/help_help.txt +9 -0
- data/lib/mysh/commands/help_math.txt +32 -39
- data/lib/mysh/commands/history.rb +3 -3
- data/lib/mysh/internal.rb +4 -3
- data/lib/mysh/support/command_pool.rb +54 -0
- data/lib/mysh/support/decorate.rb +1 -1
- data/lib/mysh/support/format.rb +1 -9
- data/lib/mysh/support/frame.rb +1 -1
- data/lib/mysh/support/handlebars.rb +1 -1
- data/lib/mysh/support/manage.rb +2 -23
- data/lib/mysh/support/parse.rb +2 -2
- data/lib/mysh/version.rb +1 -1
- data/tests/my_shell_tests.rb +11 -13
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d1ba8a1e0f44a3d96f072108abe9bba55aefebf
|
4
|
+
data.tar.gz: f5811e7f8aeba916be0b9dccd4864282314cb0f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a81089b6f2bf37d034eb8d1860774999e531ac34042d371dc9348090639f232c4d177cbfaee70220e24f68bd7a4e63420d39ba5fa983d14a1d3034a92d0bf432
|
7
|
+
data.tar.gz: 57a32385f635325c19ea131c79c1e8463ec7f405ff11a4e35934a64bae57baf54b07c8069c7050ce9f4b7f353b492d289f66fc854d97399437ce8c8c1439bef3
|
data/README.md
CHANGED
@@ -20,6 +20,9 @@ command shell within Ruby applications and Rails web sites.
|
|
20
20
|
See the original article at:
|
21
21
|
(http://www.blackbytes.info/2016/07/writing-a-shell-in-ruby/)
|
22
22
|
|
23
|
+
By the way. The briefest look at the code will reveal that mysh has grown to be
|
24
|
+
way more than 25 lines long. Gotta love dem features!
|
25
|
+
|
23
26
|
## Installation
|
24
27
|
|
25
28
|
Add this line to your application's Gemfile:
|
@@ -80,45 +83,37 @@ mysh> =cos(PI)
|
|
80
83
|
|
81
84
|
The following table describes the available math functions.
|
82
85
|
|
83
|
-
Function |
|
84
|
-
|
85
|
-
acos(x) |Float
|
86
|
-
acosh(x) |Float
|
87
|
-
asin(x) |Float
|
88
|
-
asinh(x) |Float
|
89
|
-
atan(x) |Float
|
90
|
-
atan2(y,x) |Float
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
| |Returns a Float in the range -1.0..1.0.
|
115
|
-
sinh(x) |Float |Computes the hyperbolic sine of x (expressed in radians).
|
116
|
-
sqrt(x) |Float |Returns the non-negative square root of x.
|
117
|
-
tan(x) |Float |Computes the tangent of x (expressed in radians).
|
118
|
-
tanh(x) |Float |Computes the hyperbolic tangent of x (expressed in radians).
|
119
|
-
| |
|
120
|
-
PI |Float |The value 3.141592653589793
|
121
|
-
E |Float |The value 2.718281828459045
|
86
|
+
Function |Type |Description
|
87
|
+
-----------|------|-----------------------------------------------------
|
88
|
+
acos(x) |Float |The arc cosine of x. Returns 0..π.
|
89
|
+
acosh(x) |Float |The inverse hyperbolic cosine of x.
|
90
|
+
asin(x) |Float |The arc sine of x. Returns -π/2..π/2.
|
91
|
+
asinh(x) |Float |The inverse hyperbolic sine of x.
|
92
|
+
atan(x) |Float |The arc tangent of x. Returns -π/2..π/2.
|
93
|
+
atan2(y,x) |Float |The arc tangent given y and x. Returns -π..π.
|
94
|
+
atanh(x) |Float |The inverse hyperbolic tangent of x.
|
95
|
+
cbrt(x) |Float |The cube root of x. (∛x)
|
96
|
+
cos(x) |Float |The cosine of x (in radians). Returns -1.0..1.0.
|
97
|
+
cosh(x) |Float |The hyperbolic cosine of x (in radians).
|
98
|
+
erf(x) |Float |The error function of x.
|
99
|
+
erfc(x) |Float |The complementary error function of x.
|
100
|
+
exp(x) |Float |Raise e to the power of x. (e<sup>x</sup>).
|
101
|
+
frexp(x) |Array |Extracts a two-element array containing [fraction, exponent].
|
102
|
+
gamma(x) |Float |The gamma function of x. (Γx).
|
103
|
+
hypot(x,y) |Float |The hypotenuse of a right-angled triangle. √(x² + y²)
|
104
|
+
ldexp(m,e) |Float |Builds a value where f is the fraction and e is the exponent.
|
105
|
+
lgamma(x) |Array |Builds a two-element array [ln(|Γx|), sign(Γx)]
|
106
|
+
log(x) |Float |The natural log of x. (log<sub>e</sub> x) or (ln x).
|
107
|
+
log(x,b) |Float |The base b log of x. (log<sub>b</sub> x).
|
108
|
+
log10(x) |Float |The base 10 log of x. (log<sub>10</sub> x).
|
109
|
+
log2(x) |Float |The base 2 log of x. (log<sub>2</sub> x).
|
110
|
+
sin(x) |Float |The sine of x (in radians). Returns -1.0..1.0.
|
111
|
+
sinh(x) |Float |The hyperbolic sine of x (in radians).
|
112
|
+
sqrt(x) |Float |The non-negative square root of x. (√x).
|
113
|
+
tan(x) |Float |The tangent of x (in radians).
|
114
|
+
tanh(x) |Float |The hyperbolic tangent of x (in radians).
|
115
|
+
E |Float |The value e (2.718281828459045)
|
116
|
+
PI |Float |The value π (3.141592653589793)
|
122
117
|
|
123
118
|
#### Internal mysh commands:
|
124
119
|
|
@@ -129,8 +124,8 @@ The following set of commands are supported:
|
|
129
124
|
```
|
130
125
|
! Display the mysh command history.
|
131
126
|
? Display help information for mysh.
|
132
|
-
cd <dir> Change directory to the optional <dir> parameter
|
133
|
-
|
127
|
+
cd <dir> Change directory to the optional <dir> parameter
|
128
|
+
and then display the current working directory.
|
134
129
|
exit Exit mysh.
|
135
130
|
help Display help information for mysh.
|
136
131
|
history Display the mysh command history.
|
data/lib/mysh.rb
CHANGED
@@ -31,9 +31,9 @@ module Mysh
|
|
31
31
|
input = @input.readline(prompt: 'mysh>')
|
32
32
|
|
33
33
|
begin
|
34
|
-
@exec_host.execute(input)
|
35
|
-
|
36
|
-
ruby_execute(input)
|
34
|
+
@exec_host.execute(input) ||
|
35
|
+
Command.execute(input) ||
|
36
|
+
ruby_execute(input) ||
|
37
37
|
system(input)
|
38
38
|
rescue Interrupt => err
|
39
39
|
puts err
|
data/lib/mysh/commands/cd.rb
CHANGED
@@ -4,12 +4,12 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#* cd.rb -- The mysh internal cd command.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
#Add the cd command to the library.
|
9
|
-
desc = ['Change directory to the optional <dir> parameter
|
10
|
-
'
|
9
|
+
desc = ['Change directory to the optional <dir> parameter',
|
10
|
+
'and then display the current working directory.']
|
11
11
|
|
12
|
-
add('cd <dir>', desc) do |args|
|
12
|
+
COMMANDS.add('cd <dir>', desc) do |args|
|
13
13
|
begin
|
14
14
|
Dir.chdir(args[0]) unless args.empty?
|
15
15
|
puts decorate(Dir.pwd)
|
@@ -19,7 +19,7 @@ module Mysh
|
|
19
19
|
end
|
20
20
|
|
21
21
|
#Add the pwd command to the library.
|
22
|
-
add('pwd', 'Display the current working directory.') do |args|
|
22
|
+
COMMANDS.add('pwd', 'Display the current working directory.') do |args|
|
23
23
|
begin
|
24
24
|
puts decorate(Dir.pwd)
|
25
25
|
rescue => err
|
data/lib/mysh/commands/exit.rb
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#* exit.rb -- The mysh internal exit command.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
#Add the exit command to the library.
|
9
|
-
add('exit', 'Exit mysh.') do |args|
|
9
|
+
COMMANDS.add('exit', 'Exit mysh.') do |args|
|
10
10
|
raise MiniReadlineEOI
|
11
11
|
end
|
12
12
|
|
13
|
-
add_alias('quit', 'exit')
|
13
|
+
COMMANDS.add_alias('quit', 'exit')
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
data/lib/mysh/commands/help.rb
CHANGED
@@ -4,20 +4,39 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#* help.rb -- The mysh internal help command.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
|
9
|
-
|
9
|
+
# Help topics
|
10
|
+
HELP = CommandPool.new do |args|
|
11
|
+
puts "No help found for #{args[0].inspect}."
|
12
|
+
end
|
13
|
+
|
14
|
+
HELP.add("", "General help on mysh.") do |args|
|
15
|
+
show_file('help.txt')
|
16
|
+
end
|
17
|
+
|
18
|
+
HELP.add("math", "Help on mysh math functions.") do |args|
|
19
|
+
show_file('help_math.txt')
|
20
|
+
end
|
21
|
+
|
22
|
+
HELP.add("=", "Help on mysh ruby expressions.") do |args|
|
23
|
+
show_file('help_expr.txt')
|
24
|
+
end
|
25
|
+
|
26
|
+
HELP.add("help", "Help on mysh help.") do |args|
|
27
|
+
show_file('help_help.txt')
|
28
|
+
end
|
29
|
+
|
30
|
+
HELP.add_alias('?', 'help')
|
10
31
|
|
11
|
-
|
12
|
-
|
13
|
-
HELP['ruby'] = lambda {|_args| show_file('help_ruby.txt') }
|
32
|
+
# The base help command.
|
33
|
+
desc = 'Display help information for mysh with an optional topic.'
|
14
34
|
|
15
|
-
|
16
|
-
|
17
|
-
instance_exec(args, &HELP[args[0]])
|
35
|
+
COMMANDS.add('help <topic>', desc) do |args|
|
36
|
+
HELP[args[0] || ""].execute(args)
|
18
37
|
end
|
19
38
|
|
20
|
-
add_alias('?', 'help')
|
39
|
+
COMMANDS.add_alias('? <topic>', 'help')
|
21
40
|
|
22
41
|
end
|
23
42
|
|
data/lib/mysh/commands/help.txt
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
mysh (MY ruby SHell) version: {{ Mysh::VERSION }}
|
2
2
|
|
3
|
+
The mysh is a shell program inspired by the Ruby programming language in the
|
4
|
+
same way the csh was inspired by the "C" programming language. The name rsh
|
5
|
+
was already widely in use so it was mysh for some extra ego.
|
6
|
+
|
3
7
|
In mysh, commands fall into one of three broad categories. There are:
|
4
8
|
|
5
9
|
1) Ruby expressions:
|
@@ -8,7 +12,7 @@ Any line beginning with an equals "=" sign will be evaluated as a Ruby
|
|
8
12
|
expression. This allows the mysh command line to serve as a programming,
|
9
13
|
debugging and super-calculator environment.
|
10
14
|
|
11
|
-
For more information on ruby expressions use the 'help
|
15
|
+
For more information on ruby expressions use the 'help =' command.
|
12
16
|
|
13
17
|
Note: This environment includes support for advanced mathematical operations.
|
14
18
|
For more information on this feature, use the 'help math' command.
|
@@ -20,7 +24,7 @@ the name of an internal command is processed internally by mysh.
|
|
20
24
|
|
21
25
|
The following set of commands are supported:
|
22
26
|
|
23
|
-
{{ format_items(
|
27
|
+
{{ format_items(COMMANDS.command_info).join("\n") }}
|
24
28
|
|
25
29
|
3) External commands:
|
26
30
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
mysh Math support summary
|
1
|
+
mysh Math support summary:
|
2
2
|
|
3
3
|
The Ruby expression execution environment has direct access to many advanced
|
4
4
|
mathematical functions and values.
|
@@ -8,43 +8,36 @@ For example, to compute the cosine of 3.141592653589793 use:
|
|
8
8
|
mysh> =cos(PI)
|
9
9
|
-1.0
|
10
10
|
|
11
|
-
Method
|
12
|
-
=======
|
13
|
-
acos(x) Float
|
14
|
-
acosh(x) Float
|
15
|
-
asin(x) Float
|
16
|
-
asinh(x) Float
|
17
|
-
atan(x) Float
|
18
|
-
atan2(y,x) Float
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
log2(x) Float Returns the base 2 logarithm of x.
|
41
|
-
sin(x) Float Computes the sine of x (expressed in radians).
|
42
|
-
Returns a Float in the range -1.0..1.0.
|
43
|
-
sinh(x) Float Computes the hyperbolic sine of x (expressed in radians).
|
44
|
-
sqrt(x) Float Returns the non-negative square root of x.
|
45
|
-
tan(x) Float Computes the tangent of x (expressed in radians).
|
46
|
-
tanh(x) Float Computes the hyperbolic tangent of x (expressed in radians).
|
11
|
+
Method Type Description
|
12
|
+
======= ===== ================================================
|
13
|
+
acos(x) Float The arc cosine of x. Returns 0..PI.
|
14
|
+
acosh(x) Float The inverse hyperbolic cosine of x.
|
15
|
+
asin(x) Float The arc sine of x. Returns -PI/2..PI/2.
|
16
|
+
asinh(x) Float The inverse hyperbolic sine of x.
|
17
|
+
atan(x) Float The arc tangent of x. Returns -PI/2..PI/2.
|
18
|
+
atan2(y,x) Float The arc tangent given y and x. Returns -PI..PI.
|
19
|
+
atanh(x) Float The inverse hyperbolic tangent of x.
|
20
|
+
cbrt(x) Float The cube root of x.
|
21
|
+
cos(x) Float The cosine of x (in radians). Returns -1.0..1.0.
|
22
|
+
cosh(x) Float The hyperbolic cosine of x (in radians).
|
23
|
+
erf(x) Float The error function of x.
|
24
|
+
erfc(x) Float The complementary error function of x.
|
25
|
+
exp(x) Float Raise e to the xth. (e**x).
|
26
|
+
frexp(x) Array Extracts a two-element array containing [fraction, exponent].
|
27
|
+
gamma(x) Float The gamma function of x.
|
28
|
+
hypot(x,y) Float The hypotenuse of a right-angled triangle with sides x & y.
|
29
|
+
ldexp(f,e) Float Builds a value where f is the fraction and e is the exponent.
|
30
|
+
lgamma(x) Array Builds a two-element array [ln(gamma(x)), sign(gamma(x))]
|
31
|
+
log(x) Float The natural log of x.
|
32
|
+
log(x,B) Float The base B log of x.
|
33
|
+
log10(x) Float The base 10 logarithm of x.
|
34
|
+
log2(x) Float The base 2 logarithm of x.
|
35
|
+
sin(x) Float The sine of x (in radians). Returns -1.0..1.0.
|
36
|
+
sinh(x) Float The hyperbolic sine of x (in radians).
|
37
|
+
sqrt(x) Float The non-negative square root of x.
|
38
|
+
tan(x) Float The tangent of x (in radians).
|
39
|
+
tanh(x) Float The hyperbolic tangent of x (in radians).
|
47
40
|
|
48
|
-
|
49
|
-
|
41
|
+
E Float The value 2.718281828459045
|
42
|
+
PI Float The value 3.141592653589793
|
50
43
|
|
@@ -4,9 +4,9 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#* history.rb -- The mysh internal history command.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
#Add the exit command to the library.
|
9
|
-
add('history', 'Display the mysh command history.') do |args|
|
9
|
+
COMMANDS.add('history', 'Display the mysh command history.') do |args|
|
10
10
|
history = Mysh.input.history
|
11
11
|
|
12
12
|
#The history command should not be part of the history.
|
@@ -15,7 +15,7 @@ module Mysh
|
|
15
15
|
puts history
|
16
16
|
end
|
17
17
|
|
18
|
-
add_alias('!', 'history')
|
18
|
+
COMMANDS.add_alias('!', 'history')
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/mysh/internal.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
require_relative 'commands/command_path'
|
4
|
+
require_relative 'support/frame'
|
5
|
+
require_relative 'support/command_pool'
|
3
6
|
require_relative 'support/manage'
|
4
7
|
require_relative 'support/parse'
|
5
8
|
require_relative 'support/format'
|
6
|
-
require_relative 'support/frame'
|
7
9
|
require_relative 'support/decorate'
|
8
|
-
require_relative 'commands/command_path'
|
9
10
|
require_relative 'support/handlebars'
|
10
11
|
|
11
12
|
#Load up the internal commands!
|
12
|
-
Dir[Mysh::
|
13
|
+
Dir[Mysh::Command::COMMAND_PATH + '*.rb'].each {|file| require file }
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
#* support/command_pool.rb -- A managed hash of mysh commands.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
#* support/command_pool.rb -- A managed hash of mysh commands.
|
7
|
+
class CommandPool
|
8
|
+
|
9
|
+
#Create a new command pool
|
10
|
+
def initialize(&default_action)
|
11
|
+
@pool = {}
|
12
|
+
|
13
|
+
if default_action
|
14
|
+
@pool.default = Command.new("", "", &default_action)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#Get a command.
|
19
|
+
def [](index)
|
20
|
+
@pool[index]
|
21
|
+
end
|
22
|
+
|
23
|
+
#Add a command.
|
24
|
+
def add(name, description, &action)
|
25
|
+
split_name = name.split[0] || ""
|
26
|
+
|
27
|
+
@pool[split_name] = Command.new(name, description, &action)
|
28
|
+
end
|
29
|
+
|
30
|
+
#Add an alias for an existing command.
|
31
|
+
def add_alias(new_name, old_name)
|
32
|
+
unless (command = @pool[old_name])
|
33
|
+
fail "Error adding alias #{new_name} for #{old_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
split_name = new_name.split[0]
|
37
|
+
|
38
|
+
@pool[split_name] =
|
39
|
+
Command.new(new_name, command.description, &command.action)
|
40
|
+
end
|
41
|
+
|
42
|
+
#Get information on all commands.
|
43
|
+
def command_info
|
44
|
+
@pool
|
45
|
+
.values
|
46
|
+
.map {|command| command.command_info }
|
47
|
+
.sort {|first, second| first[0] <=> second[0] }
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
end
|
54
|
+
|
data/lib/mysh/support/format.rb
CHANGED
@@ -4,15 +4,7 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#The mysh internal command class level report formatting.
|
7
|
-
class
|
8
|
-
|
9
|
-
#Get information on all commands.
|
10
|
-
def self.command_info
|
11
|
-
@commands
|
12
|
-
.values
|
13
|
-
.map {|command| command.command_info }
|
14
|
-
.sort {|first, second| first[0] <=> second[0] }
|
15
|
-
end
|
7
|
+
class Command
|
16
8
|
|
17
9
|
#Display an array of items.
|
18
10
|
def display_items(items)
|
data/lib/mysh/support/frame.rb
CHANGED
data/lib/mysh/support/manage.rb
CHANGED
@@ -4,31 +4,10 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#The mysh internal command class level data and methods.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
|
9
9
|
#Set up the command library hash.
|
10
|
-
|
11
|
-
|
12
|
-
class << self
|
13
|
-
#The command library, a hash.
|
14
|
-
attr_reader :commands
|
15
|
-
end
|
16
|
-
|
17
|
-
#Add a command to the command library.
|
18
|
-
def self.add(name, description, &action)
|
19
|
-
@commands[name.split[0]] = new(name, description, &action)
|
20
|
-
end
|
21
|
-
|
22
|
-
#Add an alias for an existing command.
|
23
|
-
def self.add_alias(new_name, old_name)
|
24
|
-
unless (command = @commands[old_name])
|
25
|
-
fail "Error adding alias #{new_name} for #{old_name}"
|
26
|
-
end
|
27
|
-
|
28
|
-
@commands[new_name] = new(new_name.split[0],
|
29
|
-
command.description,
|
30
|
-
&command.action)
|
31
|
-
end
|
10
|
+
COMMANDS = CommandPool.new
|
32
11
|
|
33
12
|
#Execute an internal command
|
34
13
|
def self.execute(str)
|
data/lib/mysh/support/parse.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#The mysh internal command instance data and methods.
|
7
|
-
class
|
7
|
+
class Command
|
8
8
|
|
9
9
|
#Parse a command string for use by commands.
|
10
10
|
#<br>Endemic Code Smells
|
@@ -22,7 +22,7 @@ module Mysh
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
[
|
25
|
+
[COMMANDS[result.shift], result]
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
data/lib/mysh/version.rb
CHANGED
data/tests/my_shell_tests.rb
CHANGED
@@ -13,34 +13,32 @@ class MyShellTester < Minitest::Test
|
|
13
13
|
|
14
14
|
def test_that_module_entities_exists
|
15
15
|
assert_equal(Module, Mysh.class)
|
16
|
-
assert_equal(Class, Mysh::
|
16
|
+
assert_equal(Class, Mysh::Command.class)
|
17
17
|
assert_equal(Class, Mysh::ExecHost.class)
|
18
18
|
end
|
19
19
|
|
20
20
|
def test_for_internal_commands
|
21
|
-
assert(Mysh::
|
22
|
-
assert(Mysh::
|
21
|
+
assert(Mysh::Command::COMMANDS['exit'], "The exit command is missing.")
|
22
|
+
assert(Mysh::Command::COMMANDS['quit'], "The quit command is missing.")
|
23
23
|
|
24
|
-
assert(Mysh::
|
25
|
-
assert(Mysh::
|
24
|
+
assert(Mysh::Command::COMMANDS['history'], "The history command is missing.")
|
25
|
+
assert(Mysh::Command::COMMANDS['!'], "The ! command is missing.")
|
26
26
|
|
27
|
-
assert(Mysh::
|
28
|
-
assert(Mysh::
|
27
|
+
assert(Mysh::Command::COMMANDS['help'], "The help command is missing.")
|
28
|
+
assert(Mysh::Command::COMMANDS['?'], "The ? command is missing.")
|
29
29
|
|
30
|
-
assert(Mysh::
|
31
|
-
assert(Mysh::
|
30
|
+
assert(Mysh::Command::COMMANDS['cd'], "The cd command is missing.")
|
31
|
+
assert(Mysh::Command::COMMANDS['pwd'], "The pwd command is missing.")
|
32
32
|
|
33
|
-
assert_raises { Mysh::
|
33
|
+
assert_raises { Mysh::Command::COMMANDS.add_alias('blam', 'shazzam') }
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_handlebars
|
37
|
-
cmd = Mysh::
|
37
|
+
cmd = Mysh::Command::COMMANDS['help']
|
38
38
|
|
39
39
|
assert_equal("ABC 123 DEF",
|
40
40
|
cmd.expand_handlebars("ABC {{ (1..3).to_a.join }} DEF"))
|
41
41
|
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
44
|
end
|
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.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Camilleri
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,13 +156,15 @@ files:
|
|
156
156
|
- lib/mysh/commands/exit.rb
|
157
157
|
- lib/mysh/commands/help.rb
|
158
158
|
- lib/mysh/commands/help.txt
|
159
|
+
- lib/mysh/commands/help_expr.txt
|
160
|
+
- lib/mysh/commands/help_help.txt
|
159
161
|
- lib/mysh/commands/help_math.txt
|
160
|
-
- lib/mysh/commands/help_ruby.txt
|
161
162
|
- lib/mysh/commands/history.rb
|
162
163
|
- lib/mysh/expression.rb
|
163
164
|
- lib/mysh/external_ruby.rb
|
164
165
|
- lib/mysh/internal.rb
|
165
166
|
- lib/mysh/smart_source.rb
|
167
|
+
- lib/mysh/support/command_pool.rb
|
166
168
|
- lib/mysh/support/decorate.rb
|
167
169
|
- lib/mysh/support/format.rb
|
168
170
|
- lib/mysh/support/frame.rb
|