mysh 0.1.9 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +132 -24
- data/lib/mysh.rb +2 -1
- data/lib/mysh/commands/cd.rb +7 -5
- data/lib/mysh/commands/exit.rb +2 -2
- data/lib/mysh/commands/help.rb +7 -10
- data/lib/mysh/commands/help_head.txt +8 -0
- data/lib/mysh/commands/help_math.txt +8 -3
- data/lib/mysh/commands/help_ruby.txt +10 -9
- data/lib/mysh/commands/help_tail.txt +20 -0
- data/lib/mysh/commands/history.rb +2 -2
- data/lib/mysh/expression.rb +19 -22
- data/lib/mysh/internal.rb +6 -5
- data/lib/mysh/ruby.rb +4 -7
- data/lib/mysh/{internal → support}/decorate.rb +1 -1
- data/lib/mysh/support/format.rb +41 -0
- data/lib/mysh/{internal/instance.rb → support/frame.rb} +2 -4
- data/lib/mysh/{internal/klass.rb → support/manage.rb} +3 -8
- data/lib/mysh/{internal → support}/parse.rb +1 -1
- data/lib/mysh/version.rb +1 -1
- data/mysh.gemspec +1 -0
- metadata +23 -8
- data/lib/mysh/commands/help.txt +0 -17
- data/lib/mysh/commands/help_internal.txt +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78a7e5a670f53f7cdfb9ede87c31216f1e596a20
|
4
|
+
data.tar.gz: 2c2a24ad4aebe2b5c430d647dacccd6cb1b046d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3678b1a241def34b14cc123e19bba3ac080d7b0d95e2f7de3d92dacdda96106df6adae9b1b8fc73d0aea7b840638020f1e9a29225edb3d9833c6abfc70bdc010
|
7
|
+
data.tar.gz: 56666cd89ba7ea004e2ff507e29f8401c35704b80028eec2e199e074f836f5b225430f665f3d3d20f25ad1f7c075bfaf9518ab8761c9efc0caf722467d34bb3e
|
data/README.md
CHANGED
@@ -47,44 +47,83 @@ This prompt can be used to execute three sorts of commands:
|
|
47
47
|
|
48
48
|
* Internal commands that are processed directly by mysh
|
49
49
|
* Ruby expressions, which are preceded by the equal (=) sign.
|
50
|
-
* External commands that are passed on to the standard command shell
|
50
|
+
* External commands that are passed on to the standard command shell or the
|
51
|
+
Ruby interpreter.
|
51
52
|
|
52
53
|
From the mysh help:
|
53
54
|
|
54
55
|
mysh> ?
|
55
|
-
mysh (MY SHell) version: 0.1.
|
56
|
+
mysh (MY ruby SHell) version: 0.1.11
|
56
57
|
|
57
|
-
Internal mysh commands:
|
58
|
+
1) Internal mysh commands:
|
58
59
|
- executed by mysh directly.
|
59
|
-
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
?
|
66
|
-
cd <dir>
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
60
|
+
- supports the following set of commands.
|
61
|
+
|
62
|
+
Internal Commands
|
63
|
+
===================
|
64
|
+
|
65
|
+
! Display the mysh command history.
|
66
|
+
? Display help information for mysh.
|
67
|
+
cd <dir> Change directory to the optional <dir> parameter.
|
68
|
+
Then display the current working directory.
|
69
|
+
exit Exit mysh.
|
70
|
+
help Display help information for mysh.
|
71
|
+
history Display the mysh command history.
|
72
|
+
pwd Display the current working directory.
|
73
|
+
quit Exit mysh.
|
74
|
+
|
75
|
+
2) Ruby Expression support:
|
76
|
+
- any line beginning with an equals "=" sign will be evaluated as a Ruby
|
77
|
+
expression. This allows the mysh command line to serve as a programming,
|
78
|
+
debugging and super-calculator environment.
|
79
|
+
- for more info use the 'help ruby' command.
|
80
|
+
|
81
|
+
3) Math support:
|
74
82
|
- the execution environment includes the Math module.
|
75
|
-
- for more info use the help math command.
|
83
|
+
- for more info use the 'help math' command.
|
76
84
|
|
77
|
-
External commands:
|
85
|
+
4) External commands:
|
78
86
|
- executed by the system using the standard shell.
|
79
|
-
- use
|
87
|
+
- to force the use of the external shell, add a leading space to the command.
|
88
|
+
|
89
|
+
Note: If the command has a '.rb' extension it is executed by Ruby.
|
90
|
+
So the command "myfile.rb" is executed as "ruby myfile.rb"
|
91
|
+
|
92
|
+
and
|
93
|
+
|
94
|
+
mysh> ? ruby
|
95
|
+
mysh (MY ruby SHell) version: 0.1.11
|
96
|
+
|
97
|
+
mysh Ruby expression support summary
|
98
|
+
|
99
|
+
- All command lines that begin with an equals "=" sign are evaluated as Ruby
|
100
|
+
expressions.
|
101
|
+
- Expressions ending with a backslash character "\" are continued on the next
|
102
|
+
line. The prompt changes to "mysh\" to indicate that this is going on.
|
103
|
+
- The results are displayed using the pretty-print facility.
|
104
|
+
- Auto-complete always places any file names in quotes so they can be used
|
105
|
+
as string parameters.
|
106
|
+
|
107
|
+
A few noteworthy methods exist that facilitate use of Ruby expressions:
|
108
|
+
|
109
|
+
reset Reset the execution environment to the default state.
|
110
|
+
result Returns the result of the previous expression.
|
111
|
+
vls <mask> List modules with version info. The optional mask string value
|
112
|
+
is used to filter for modules containing that string.
|
80
113
|
|
81
114
|
and
|
82
115
|
|
83
116
|
mysh> ? math
|
84
|
-
mysh (MY SHell) version: 0.1.
|
117
|
+
mysh (MY ruby SHell) version: 0.1.11
|
85
118
|
|
86
119
|
mysh Math support summary
|
87
120
|
|
121
|
+
The Ruby expression execution environment has direct access to many advanced
|
122
|
+
Math functions. For example, to compute the cosine of 3.141592653589793 use:
|
123
|
+
|
124
|
+
mysh> =cos(PI)
|
125
|
+
-1.0
|
126
|
+
|
88
127
|
Method Returns Description
|
89
128
|
======= ======= ================================================
|
90
129
|
acos(x) Float Computes the arc cosine of x. Returns 0..PI.
|
@@ -110,8 +149,8 @@ and
|
|
110
149
|
ldexp(f,e) Float Returns the value of f*(2**e).
|
111
150
|
lgamma(x) Array Returns a two-element array containing the log of the
|
112
151
|
gamma of x and the sign of gamma of x.
|
113
|
-
log(x) Float Computes the natural log of
|
114
|
-
log(x,B) Float Computes the base B log of
|
152
|
+
log(x) Float Computes the natural log of x.
|
153
|
+
log(x,B) Float Computes the base B log of x.
|
115
154
|
log10(x) Float Returns the base 10 logarithm of x.
|
116
155
|
log2(x) Float Returns the base 2 logarithm of x.
|
117
156
|
sin(x) Float Computes the sine of x (expressed in radians).
|
@@ -121,6 +160,8 @@ and
|
|
121
160
|
tan(x) Float Computes the tangent of x (expressed in radians).
|
122
161
|
tanh(x) Float Computes the hyperbolic tangent of x (expressed in radians).
|
123
162
|
|
163
|
+
PI Float The value 3.141592653589793
|
164
|
+
E Float The value 2.718281828459045
|
124
165
|
|
125
166
|
The mysh can also be used from within a Ruby application:
|
126
167
|
|
@@ -128,6 +169,73 @@ The mysh can also be used from within a Ruby application:
|
|
128
169
|
Mysh.run
|
129
170
|
```
|
130
171
|
|
172
|
+
## Adding New Commands
|
173
|
+
|
174
|
+
It is possible to add new internal commands to the mysh CLI. This is done by
|
175
|
+
depositing the appropriate ruby file in the commands folder located at:
|
176
|
+
|
177
|
+
/mysh/lib/mysh/commands
|
178
|
+
|
179
|
+
As an example, the file cd.rb is shown to illustrate the responsibilities of
|
180
|
+
a typical command plug-in:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
# coding: utf-8
|
184
|
+
|
185
|
+
#* commands/cd.rb -- The mysh internal cd command.
|
186
|
+
module Mysh
|
187
|
+
|
188
|
+
#* cd.rb -- The mysh internal cd command.
|
189
|
+
class InternalCommand
|
190
|
+
#Add the cd command to the library.
|
191
|
+
desc = ['Change directory to the optional <dir> parameter.',
|
192
|
+
'Then display the current working directory.']
|
193
|
+
|
194
|
+
add('cd <dir>', desc) do |args|
|
195
|
+
begin
|
196
|
+
Dir.chdir(args[0]) unless args.empty?
|
197
|
+
puts decorate(Dir.pwd)
|
198
|
+
rescue => err
|
199
|
+
puts "Error: #{err}"
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
#Add the pwd command to the library.
|
204
|
+
add('pwd', 'Display the current working directory.') do |args|
|
205
|
+
begin
|
206
|
+
puts decorate(Dir.pwd)
|
207
|
+
rescue => err
|
208
|
+
puts "Error: #{err}"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
end
|
213
|
+
end
|
214
|
+
```
|
215
|
+
|
216
|
+
Note that the plug in code is contained within the InternalCommand class under
|
217
|
+
the Mysh module umbrella. The principle method used to create internal commands
|
218
|
+
is the add method:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
add(command_name, command_description) do |args|
|
222
|
+
# Action block goes here
|
223
|
+
end
|
224
|
+
```
|
225
|
+
Where:
|
226
|
+
* command_name is the name of the command with optional argument descriptions
|
227
|
+
seperated with spaces. The command is the first word of this string.
|
228
|
+
* command_description is a string or an array of strings that describe the
|
229
|
+
command.
|
230
|
+
* args is an array of zero or more arguments that were entered with the command.
|
231
|
+
|
232
|
+
Commands sometimes have more than one possible name. This is supported with:
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
add_alias(new_name, old_name)
|
236
|
+
```
|
237
|
+
|
238
|
+
|
131
239
|
## Contributing
|
132
240
|
|
133
241
|
#### Plan A
|
data/lib/mysh.rb
CHANGED
@@ -5,6 +5,7 @@
|
|
5
5
|
require 'English'
|
6
6
|
require 'mini_readline'
|
7
7
|
require 'vls'
|
8
|
+
require 'in_array'
|
8
9
|
|
9
10
|
require_relative 'mysh/smart_source'
|
10
11
|
require_relative 'mysh/expression'
|
@@ -27,7 +28,7 @@ module Mysh
|
|
27
28
|
init_run
|
28
29
|
|
29
30
|
loop do
|
30
|
-
input = @input.readline(prompt: 'mysh>
|
31
|
+
input = @input.readline(prompt: 'mysh>')
|
31
32
|
|
32
33
|
begin
|
33
34
|
@exec_host.execute(input) ||
|
data/lib/mysh/commands/cd.rb
CHANGED
@@ -6,24 +6,26 @@ module Mysh
|
|
6
6
|
#* cd.rb -- The mysh internal cd command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the cd command to the library.
|
9
|
-
desc = 'Change directory to <dir>
|
10
|
-
|
9
|
+
desc = ['Change directory to the optional <dir> parameter.',
|
10
|
+
'Then display the current working directory.']
|
11
|
+
|
12
|
+
add('cd <dir>', desc) do |args|
|
11
13
|
begin
|
12
14
|
Dir.chdir(args[0]) unless args.empty?
|
13
15
|
puts decorate(Dir.pwd)
|
14
16
|
rescue => err
|
15
17
|
puts "Error: #{err}"
|
16
18
|
end
|
17
|
-
end
|
19
|
+
end
|
18
20
|
|
19
21
|
#Add the pwd command to the library.
|
20
|
-
add(
|
22
|
+
add('pwd', 'Display the current working directory.') do |args|
|
21
23
|
begin
|
22
24
|
puts decorate(Dir.pwd)
|
23
25
|
rescue => err
|
24
26
|
puts "Error: #{err}"
|
25
27
|
end
|
26
|
-
end
|
28
|
+
end
|
27
29
|
|
28
30
|
end
|
29
31
|
end
|
data/lib/mysh/commands/exit.rb
CHANGED
@@ -6,9 +6,9 @@ module Mysh
|
|
6
6
|
#* exit.rb -- The mysh internal exit command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the exit command to the library.
|
9
|
-
add(
|
9
|
+
add('exit', 'Exit mysh.') do |args|
|
10
10
|
raise MiniReadlineEOI
|
11
|
-
end
|
11
|
+
end
|
12
12
|
|
13
13
|
add_alias('quit', 'exit')
|
14
14
|
end
|
data/lib/mysh/commands/help.rb
CHANGED
@@ -6,19 +6,14 @@ module Mysh
|
|
6
6
|
#* exit.rb -- The mysh internal exit command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the exit command to the library.
|
9
|
-
add(
|
9
|
+
add('help', 'Display help information for mysh.') do |args|
|
10
10
|
puts "mysh (MY ruby SHell) version: #{Mysh::VERSION}"
|
11
11
|
puts
|
12
12
|
|
13
13
|
if args.empty?
|
14
|
-
puts IO.read(File.dirname(__FILE__) + '/
|
15
|
-
|
16
|
-
|
17
|
-
.info
|
18
|
-
.sort {|first, second | first[0] <=> second[0] }
|
19
|
-
.each {|info| puts "#{info[0].ljust(10)} #{info[1]}" }
|
20
|
-
puts
|
21
|
-
puts IO.read(File.dirname(__FILE__) + '/help.txt')
|
14
|
+
puts IO.read(File.dirname(__FILE__) + '/help_head.txt')
|
15
|
+
InternalCommand.display_items(info)
|
16
|
+
puts IO.read(File.dirname(__FILE__) + '/help_tail.txt')
|
22
17
|
elsif args[0] == 'math'
|
23
18
|
puts IO.read(File.dirname(__FILE__) + '/help_math.txt')
|
24
19
|
elsif args[0] == 'ruby'
|
@@ -27,9 +22,11 @@ module Mysh
|
|
27
22
|
puts "help #{args[0]} ???"
|
28
23
|
end
|
29
24
|
|
30
|
-
end
|
25
|
+
end
|
31
26
|
|
32
27
|
add_alias('?', 'help')
|
28
|
+
|
33
29
|
end
|
30
|
+
|
34
31
|
end
|
35
32
|
|
@@ -1,8 +1,10 @@
|
|
1
1
|
mysh Math support summary
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
The Ruby expression execution environment has direct access to many advanced
|
4
|
+
Math functions. For example, to compute the cosine of 3.141592653589793 use:
|
5
|
+
|
6
|
+
mysh> =cos(PI)
|
7
|
+
-1.0
|
6
8
|
|
7
9
|
Method Returns Description
|
8
10
|
======= ======= ================================================
|
@@ -40,3 +42,6 @@ sqrt(x) Float Returns the non-negative square root of x.
|
|
40
42
|
tan(x) Float Computes the tangent of x (expressed in radians).
|
41
43
|
tanh(x) Float Computes the hyperbolic tangent of x (expressed in radians).
|
42
44
|
|
45
|
+
PI Float The value 3.141592653589793
|
46
|
+
E Float The value 2.718281828459045
|
47
|
+
|
@@ -1,16 +1,17 @@
|
|
1
1
|
mysh Ruby expression support summary
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
3
|
+
- All command lines that begin with an equals "=" sign are evaluated as Ruby
|
4
|
+
expressions.
|
5
|
+
- Expressions ending with a backslash character "\" are continued on the next
|
6
|
+
line. The prompt changes to "mysh\" to indicate that this is going on.
|
7
|
+
- The results are displayed using the pretty-print facility.
|
8
|
+
- Auto-complete always places any file names in quotes so they can be used
|
9
|
+
as string parameters.
|
10
10
|
|
11
11
|
A few noteworthy methods exist that facilitate use of Ruby expressions:
|
12
12
|
|
13
13
|
reset Reset the execution environment to the default state.
|
14
14
|
result Returns the result of the previous expression.
|
15
|
-
vls
|
16
|
-
|
15
|
+
vls "mask" List modules with version info. The optional mask string value is
|
16
|
+
used to filter for modules containing that string.
|
17
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
2) Ruby Expression support:
|
2
|
+
|
3
|
+
- Any line beginning with an equals "=" sign will be evaluated as a Ruby
|
4
|
+
expression. This allows the mysh command line to serve as a programming,
|
5
|
+
debugging and super-calculator environment.
|
6
|
+
- For more info use the 'help ruby' command.
|
7
|
+
|
8
|
+
3) Math support:
|
9
|
+
|
10
|
+
- The execution environment includes the Math module.
|
11
|
+
- For more info use the 'help math' command.
|
12
|
+
|
13
|
+
4) External commands:
|
14
|
+
|
15
|
+
- Executed by the system using the standard shell.
|
16
|
+
- To force the use of the external shell, add a leading space to the command.
|
17
|
+
|
18
|
+
Note: If the command has a '.rb' extension it is executed by Ruby.
|
19
|
+
So the command "myfile.rb" is executed as "ruby myfile.rb"
|
20
|
+
|
@@ -6,14 +6,14 @@ module Mysh
|
|
6
6
|
#* exit.rb -- The mysh internal history command.
|
7
7
|
class InternalCommand
|
8
8
|
#Add the exit command to the library.
|
9
|
-
add(
|
9
|
+
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.
|
13
13
|
history.pop
|
14
14
|
|
15
15
|
puts history
|
16
|
-
end
|
16
|
+
end
|
17
17
|
|
18
18
|
add_alias('!', 'history')
|
19
19
|
end
|
data/lib/mysh/expression.rb
CHANGED
@@ -17,7 +17,7 @@ module Mysh
|
|
17
17
|
#Process an expression.
|
18
18
|
def execute(str)
|
19
19
|
if str.start_with?('=')
|
20
|
-
do_execute(str)
|
20
|
+
do_execute(do_build(str))
|
21
21
|
else
|
22
22
|
false
|
23
23
|
end
|
@@ -32,33 +32,30 @@ module Mysh
|
|
32
32
|
end
|
33
33
|
|
34
34
|
private
|
35
|
-
|
35
|
+
|
36
|
+
#Gather up the full string of the expression to evaluate.
|
36
37
|
#<br>Endemic Code Smells
|
37
38
|
#* :reek:TooManyStatements
|
38
|
-
def
|
39
|
+
def do_build(str)
|
39
40
|
if /\\\s*$/ =~ str
|
40
|
-
parms = {
|
41
|
-
|
42
|
-
auto_source: MiniReadline::QuotedFileFolderSource
|
43
|
-
}
|
41
|
+
parms = {prompt: 'mysh\\',
|
42
|
+
auto_source: MiniReadline::QuotedFileFolderSource}
|
44
43
|
|
45
|
-
|
44
|
+
do_build($PREMATCH + "\n" + Mysh.input.readline(parms))
|
46
45
|
else
|
47
|
-
|
48
|
-
eval("@result" + str)
|
49
|
-
|
50
|
-
if @result
|
51
|
-
pp @result
|
52
|
-
else
|
53
|
-
puts @result
|
54
|
-
end
|
55
|
-
|
56
|
-
rescue StandardError, ScriptError => err
|
57
|
-
puts "Error: #{err}"
|
58
|
-
end
|
59
|
-
|
60
|
-
:expression
|
46
|
+
str
|
61
47
|
end
|
62
48
|
end
|
49
|
+
|
50
|
+
#Execute the string
|
51
|
+
def do_execute(str)
|
52
|
+
instance_eval("@result" + str)
|
53
|
+
send(@result ? :pp : :puts, @result)
|
54
|
+
rescue StandardError, ScriptError => err
|
55
|
+
puts "Error: #{err}"
|
56
|
+
ensure
|
57
|
+
return :expression
|
58
|
+
end
|
63
59
|
end
|
60
|
+
|
64
61
|
end
|
data/lib/mysh/internal.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
require_relative '
|
6
|
-
require_relative '
|
3
|
+
require_relative 'support/manage'
|
4
|
+
require_relative 'support/parse'
|
5
|
+
require_relative 'support/format'
|
6
|
+
require_relative 'support/frame'
|
7
|
+
require_relative 'support/decorate'
|
7
8
|
|
8
|
-
#Load up the commands!
|
9
|
+
#Load up the internal commands!
|
9
10
|
Dir[File.dirname(__FILE__) + '/commands/*.rb'].each {|file| require file }
|
data/lib/mysh/ruby.rb
CHANGED
@@ -1,19 +1,16 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
+
#* ruby.rb -- Support for executing Ruby files with the ruby interpreter.
|
3
4
|
module Mysh
|
4
5
|
|
5
6
|
#Try to execute as a Ruby program.
|
6
7
|
def self.ruby_execute(str)
|
7
|
-
if
|
8
|
-
new_command = "ruby #{str}"
|
9
|
-
|
10
|
-
puts "=> #{new_command}"
|
11
|
-
puts
|
12
|
-
|
8
|
+
if (command = str.split[0]) && File.extname(command) == '.rb'
|
9
|
+
puts "=> #{new_command = "ruby #{str}"}\n\n"
|
13
10
|
system(new_command)
|
14
11
|
:ruby_exec
|
15
12
|
end
|
16
13
|
|
17
14
|
end
|
18
15
|
|
19
|
-
end
|
16
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
#* support/format.rb -- Format mysh internal reports.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
#The mysh internal command class level report formatting.
|
7
|
+
class InternalCommand
|
8
|
+
|
9
|
+
#Get information on all commands.
|
10
|
+
def self.info
|
11
|
+
@commands
|
12
|
+
.values
|
13
|
+
.map {|command| command.info }
|
14
|
+
.sort {|first, second| first[0] <=> second[0] }
|
15
|
+
end
|
16
|
+
|
17
|
+
#Display an array of items.
|
18
|
+
def self.display_items(items)
|
19
|
+
#Determine the width of the tag area.
|
20
|
+
tag_width = items.max_by {|item| item[0].length}[0].length + 1
|
21
|
+
|
22
|
+
#Display the information.
|
23
|
+
items.each {|item| display_item(item, tag_width) }
|
24
|
+
|
25
|
+
puts
|
26
|
+
end
|
27
|
+
|
28
|
+
#Display one item.
|
29
|
+
def self.display_item(item, tag_width=nil)
|
30
|
+
tag = item[0]
|
31
|
+
tag_width ||= tag.length + 1
|
32
|
+
|
33
|
+
item[1].each do |detail|
|
34
|
+
puts "#{tag.ljust(tag_width)} #{detail}"
|
35
|
+
tag = ""
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
#*
|
3
|
+
#* support/frame.rb -- The abstract frame of mysh internal commands.
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#The mysh internal command instance data and methods.
|
@@ -16,9 +16,7 @@ module Mysh
|
|
16
16
|
|
17
17
|
#Setup an internal command
|
18
18
|
def initialize(name, description, &action)
|
19
|
-
@name
|
20
|
-
@description = description
|
21
|
-
@action = action
|
19
|
+
@name, @description, @action = name, description.in_array, action
|
22
20
|
end
|
23
21
|
|
24
22
|
#Execute the command.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
#*
|
3
|
+
#* support/manage.rb -- Manage mysh internal commands.
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
#The mysh internal command class level data and methods.
|
@@ -15,8 +15,8 @@ module Mysh
|
|
15
15
|
end
|
16
16
|
|
17
17
|
#Add a command to the command library.
|
18
|
-
def self.add(
|
19
|
-
@commands[
|
18
|
+
def self.add(name, description, &action)
|
19
|
+
@commands[name.split[0]] = new(name, description, &action)
|
20
20
|
end
|
21
21
|
|
22
22
|
#Add an alias for an existing command.
|
@@ -42,11 +42,6 @@ module Mysh
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
#Get information on all commands.
|
46
|
-
def self.info
|
47
|
-
@commands.values.map { |command| command.info }
|
48
|
-
end
|
49
|
-
|
50
45
|
end
|
51
46
|
end
|
52
47
|
|
data/lib/mysh/version.rb
CHANGED
data/mysh.gemspec
CHANGED
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.11
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: 0.3.9
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: in_array
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description: mysh -- a Ruby inspired command shell for CLI and application use.
|
126
140
|
email:
|
127
141
|
- peter.c.camilleri@gmail.com
|
@@ -140,19 +154,20 @@ files:
|
|
140
154
|
- lib/mysh/commands/cd.rb
|
141
155
|
- lib/mysh/commands/exit.rb
|
142
156
|
- lib/mysh/commands/help.rb
|
143
|
-
- lib/mysh/commands/
|
144
|
-
- lib/mysh/commands/help_internal.txt
|
157
|
+
- lib/mysh/commands/help_head.txt
|
145
158
|
- lib/mysh/commands/help_math.txt
|
146
159
|
- lib/mysh/commands/help_ruby.txt
|
160
|
+
- lib/mysh/commands/help_tail.txt
|
147
161
|
- lib/mysh/commands/history.rb
|
148
162
|
- lib/mysh/expression.rb
|
149
163
|
- lib/mysh/internal.rb
|
150
|
-
- lib/mysh/internal/decorate.rb
|
151
|
-
- lib/mysh/internal/instance.rb
|
152
|
-
- lib/mysh/internal/klass.rb
|
153
|
-
- lib/mysh/internal/parse.rb
|
154
164
|
- lib/mysh/ruby.rb
|
155
165
|
- lib/mysh/smart_source.rb
|
166
|
+
- lib/mysh/support/decorate.rb
|
167
|
+
- lib/mysh/support/format.rb
|
168
|
+
- lib/mysh/support/frame.rb
|
169
|
+
- lib/mysh/support/manage.rb
|
170
|
+
- lib/mysh/support/parse.rb
|
156
171
|
- lib/mysh/version.rb
|
157
172
|
- mysh.gemspec
|
158
173
|
- rakefile.rb
|
data/lib/mysh/commands/help.txt
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
2) Ruby Expression support:
|
2
|
-
- any line beginning with an equals "=" sign will be evaluated as a Ruby
|
3
|
-
expression. This allows the mysh command line to serve as a programming,
|
4
|
-
debugging and super-calculator environment.
|
5
|
-
- for more info use the 'help ruby' command.
|
6
|
-
|
7
|
-
3) Math support:
|
8
|
-
- the execution environment includes the Math module.
|
9
|
-
- for more info use the 'help math' command.
|
10
|
-
|
11
|
-
4) External commands:"
|
12
|
-
- executed by the system using the standard shell.
|
13
|
-
- to force the use of the external shell, add a leading space to the command.
|
14
|
-
|
15
|
-
Note: If the command has a '.rb' extension it is executed by Ruby.
|
16
|
-
So the command "myfile.rb" is executed as "ruby myfile.rb"
|
17
|
-
|