mysh 0.5.4 → 0.5.5
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 +25 -11
- data/lib/mysh/expression.rb +4 -1
- data/lib/mysh/init.rb +1 -1
- data/lib/mysh/input_wrapper.rb +3 -2
- data/lib/mysh/internal.rb +1 -1
- data/lib/mysh/internal/action_pool.rb +1 -1
- data/lib/mysh/internal/actions/cd.rb +1 -1
- data/lib/mysh/internal/actions/command_line/init.rb +1 -1
- data/lib/mysh/internal/actions/command_line/load.rb +1 -1
- data/lib/mysh/internal/actions/help/args.txt +20 -0
- data/lib/mysh/internal/actions/help/env.txt +1 -0
- data/lib/mysh/internal/actions/help/gls.txt +0 -1
- data/lib/mysh/internal/actions/help/init.txt +32 -0
- data/lib/mysh/internal/actions/help/mls.txt +25 -0
- data/lib/mysh/internal/actions/help/sub_help.rb +6 -1
- data/lib/mysh/internal/actions/help/timed.txt +18 -0
- data/lib/mysh/internal/actions/help/types.txt +18 -0
- data/lib/mysh/internal/actions/help/vars.txt +2 -0
- data/lib/mysh/internal/actions/history.rb +1 -1
- data/lib/mysh/internal/actions/load.rb +1 -1
- data/lib/mysh/internal/actions/{vls.rb → mls.rb} +4 -5
- data/lib/mysh/internal/actions/pwd.rb +1 -1
- data/lib/mysh/internal/actions/show/env.rb +9 -6
- data/lib/mysh/internal/actions/show/ruby.rb +1 -1
- data/lib/mysh/internal/actions/type.rb +1 -1
- data/lib/mysh/internal/{decorate.rb → to_file_spec.rb} +6 -2
- data/lib/mysh/shell_variables.rb +4 -3
- data/lib/mysh/shell_variables/evaluate.rb +3 -2
- data/lib/mysh/version.rb +1 -1
- data/tests/my_shell_tests.rb +21 -1
- metadata +9 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f28af55da066abdf2b23c0dc611aa50a3df29fb
|
4
|
+
data.tar.gz: aa51017dff9ea5eecd03e13a4779df9a8d5d8cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 480fb4f616671c91a265c828230d69acd23294c4b4bce7a147632b4cff1d7789fb8e271de80d3154218b28bd87d85a28562df7659e2a1cd33eef2344a19c2be4
|
7
|
+
data.tar.gz: 579b5dbf09be38d59e7d9cf8178c853a14bcdd68b5d21d9da183d4d45da2503ed3874b408dda5fb024bfb461e1d59f4248428087db08471706594aa14c0138b7
|
data/README.md
CHANGED
@@ -220,7 +220,7 @@ To assist in the creation of well formatted output, the mysh environment
|
|
220
220
|
provides a number of "helper" methods in the Array and String classes. These
|
221
221
|
are:
|
222
222
|
|
223
|
-
* String#
|
223
|
+
* String#to_host_spec - given a string with a file path/name value, express that
|
224
224
|
string in a manner compatible with the current operating environment.
|
225
225
|
* Array#format_mysh_columns - take an array and convert it to a string with nice
|
226
226
|
regular columns.
|
@@ -232,7 +232,7 @@ bullet points. The appearance of each point depends on its structure. See below:
|
|
232
232
|
This must all be confusing. Some examples may help:
|
233
233
|
|
234
234
|
```
|
235
|
-
mysh>=puts "lib/mysh/expression/lineage.rb".
|
235
|
+
mysh>=puts "lib/mysh/expression/lineage.rb".to_host_spec
|
236
236
|
lib\mysh\expression\lineage.rb
|
237
237
|
|
238
238
|
mysh>=(1..100).to_a.puts_mysh_columns
|
@@ -376,6 +376,8 @@ $h | The home folder's path
|
|
376
376
|
$post_prompt| The prompt used when a line is continued with a trailing \\ character. By default this is the same as the normal prompt.
|
377
377
|
$pre_prompt | A prompt string displayed before the actual command prompt. Delete the pre_prompt variable to disable pre-prompting.
|
378
378
|
$prompt | The user prompt.
|
379
|
+
$r | The location of the Ruby compiler.
|
380
|
+
$s | The location of the host command interpreter.
|
379
381
|
$t | The current time.
|
380
382
|
$time_fmt | The format for the time: "%H:%M"
|
381
383
|
$u | The current user.
|
@@ -391,9 +393,9 @@ environment. Just a few reminders:
|
|
391
393
|
|
392
394
|
* Any line beginning with an equals "=" sign will be evaluated as a Ruby
|
393
395
|
expression.
|
394
|
-
* Expressions ending with a backslash character "
|
395
|
-
line. The prompt changes to end with a "
|
396
|
-
going on.
|
396
|
+
* Expressions ending with a backslash character "\\" are continued on the next
|
397
|
+
line. The prompt changes to end with a "\\" character to indicate that this
|
398
|
+
is going on.
|
397
399
|
* The results of the expression are displayed using the pretty-print facility.
|
398
400
|
* Auto-complete always places any file names in quotes so they can be used
|
399
401
|
as string parameters.
|
@@ -476,18 +478,23 @@ Topic | Description
|
|
476
478
|
none | General help on mysh.
|
477
479
|
! | Help on the history command.
|
478
480
|
$ | Help on mysh variables.
|
481
|
+
% | Help on timed command execution.
|
479
482
|
= | Help on ruby expressions.
|
480
483
|
? | This help on the help command.
|
481
484
|
@ | Help on the show command.
|
485
|
+
args | Help on mysh command arguments.
|
482
486
|
env | Help on the show env command.
|
483
487
|
gls | Help on gls internal mysh command.
|
484
488
|
help | This help on the help command.
|
485
489
|
history | Help on the history command.
|
490
|
+
init | Help on mysh initialization.
|
486
491
|
kbd | Help on mysh keyboard mapping.
|
487
492
|
math | Help on math functions.
|
493
|
+
mls | Help on mls internal mysh command.
|
488
494
|
quick | Help on quick commands.
|
489
495
|
ruby | Help on the show ruby command.
|
490
496
|
show | Help on the show command.
|
497
|
+
types | Help on mysh file types.
|
491
498
|
usage | Help on mysh usage options.
|
492
499
|
{{ | Help on mysh handlebars.
|
493
500
|
|
@@ -507,6 +514,7 @@ environment.
|
|
507
514
|
|
508
515
|
Topic | Description
|
509
516
|
---------|----------------------------------------------------
|
517
|
+
about | A brief description of the mysh shell program.
|
510
518
|
version | The version of mysh in use.
|
511
519
|
init file| The init file in use or <none found> or <none>.
|
512
520
|
user | The current user name.
|
@@ -556,14 +564,14 @@ Command | Description
|
|
556
564
|
---------------|----------------------------------------------------
|
557
565
|
cd {dir} | Change directory to the optional dir parameter and then display the current working directory.
|
558
566
|
exit | Exit mysh.
|
559
|
-
gls {-l} {mask}| Display the loaded ruby gems.
|
567
|
+
gls {-l} {mask}| Display the loaded ruby gems. See ?gls for more.
|
560
568
|
history {index}| The mysh command history. If an index is specified, get the command with that index value.
|
561
569
|
load file | Load a ruby program, mysh script, or text file into the mysh environment.
|
570
|
+
mls {mask} | Display modules with version info. See ?mls for more.
|
562
571
|
pwd | Display the current working directory.
|
563
572
|
quit | Exit mysh.
|
564
573
|
say <stuff> | Display the text in the command arguments.
|
565
574
|
type file | Display a text file with support for optional embedded handlebars and mysh variables.
|
566
|
-
vls {mask} | Display the loaded modules, matching the optional mask, that have version info.
|
567
575
|
|
568
576
|
Notes:
|
569
577
|
1. The notation {x} means that x is optional.
|
@@ -600,7 +608,7 @@ Extension | Description
|
|
600
608
|
---------------|----------------------------------------------------
|
601
609
|
.rb | A ruby source file executed via a new instance of the compiler.
|
602
610
|
.mysh | A mysh script file. Commands in this file are executed as if the user typed them in at the console.
|
603
|
-
.txt | A text file. The file (with any embedded code and
|
611
|
+
.txt | A text file. The file (with any embedded code and variables) is displayed on the console.
|
604
612
|
|
605
613
|
Here is a sample session with an external Ruby program.
|
606
614
|
|
@@ -764,11 +772,17 @@ Process the string for embedded variables and handlebars. By default,
|
|
764
772
|
any embedded ruby is evaluated in the mysh global expression binding. However,
|
765
773
|
another BindingWrapper instance may be passed to access an alternative binding.
|
766
774
|
|
767
|
-
###### "string".
|
768
|
-
Given a string with a file spec,
|
769
|
-
pleasing to the local environment. This is a great boon to writing
|
775
|
+
###### "string".to_host_spec
|
776
|
+
Given a string with a file spec, to_host_spec adjusts that string so that it is
|
777
|
+
more pleasing to the local environment. This is a great boon to writing
|
778
|
+
effortless portable code.
|
779
|
+
|
780
|
+
###### "string".to_std_spec
|
781
|
+
Given a string with a file spec, to_std_spec adjusts that string so that it is
|
782
|
+
compatible with standard usage. This is a great boon to writing effortless
|
770
783
|
portable code.
|
771
784
|
|
785
|
+
|
772
786
|
#### Adding Help Topics
|
773
787
|
|
774
788
|
In mysh, help topics are generally implemented as text files often augmented
|
data/lib/mysh/expression.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
3
|
require 'pp'
|
4
|
-
require 'mathn'
|
5
4
|
require_relative 'expression/lineage'
|
6
5
|
|
7
6
|
#* mysh/expression.rb -- The mysh ruby expression processor.
|
@@ -9,6 +8,10 @@ require_relative 'expression/lineage'
|
|
9
8
|
#* :reek:ModuleInitialize -- False positive
|
10
9
|
module Mysh
|
11
10
|
|
11
|
+
#Set up some popular constants
|
12
|
+
E = Math::E
|
13
|
+
PI = Math::PI
|
14
|
+
|
12
15
|
#Reset the state of the execution hosting environment.
|
13
16
|
#<br>Endemic Code Smells
|
14
17
|
# :reek:TooManyStatements -- False positive
|
data/lib/mysh/init.rb
CHANGED
data/lib/mysh/input_wrapper.rb
CHANGED
@@ -32,7 +32,7 @@ module Mysh
|
|
32
32
|
|
33
33
|
#Get the parameter text.
|
34
34
|
def raw_body
|
35
|
-
@raw_body ||= @raw[(raw_command.length)..-1]
|
35
|
+
@raw_body ||= @raw[(raw_command.length + 1)..-1] || ""
|
36
36
|
end
|
37
37
|
|
38
38
|
#Get the preprocessed argument text.
|
@@ -42,7 +42,8 @@ module Mysh
|
|
42
42
|
|
43
43
|
#Access the massaged text.
|
44
44
|
def cooked
|
45
|
-
|
45
|
+
body = cooked_body
|
46
|
+
raw_command + (body.empty? ? "" : " " + body)
|
46
47
|
end
|
47
48
|
|
48
49
|
#Get the parsed arguments
|
data/lib/mysh/internal.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'internal/action'
|
|
5
5
|
require_relative 'internal/action_pool'
|
6
6
|
require_relative 'internal/manage'
|
7
7
|
require_relative 'internal/format'
|
8
|
-
require_relative 'internal/
|
8
|
+
require_relative 'internal/to_file_spec'
|
9
9
|
|
10
10
|
#Load up the internal actions!
|
11
11
|
Dir[Mysh::Action::ACTIONS_PATH + '*.rb'].each {|file| require file }
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Available mysh command line arguments are:
|
2
|
+
|
3
|
+
Option+Short Forms Description Default
|
4
|
+
================== =========== =======
|
5
|
+
--debug -d Turn on mysh debugging. false
|
6
|
+
--no-debug -nd Turn off mysh debugging.
|
7
|
+
--help -? -h Display mysh usage info and exit.
|
8
|
+
--init -i <name> Initialize mysh by loading the specified file.*
|
9
|
+
--no-init -ni Do not load a file to initialize mysh.
|
10
|
+
--load -l <name> Load the specified file into the mysh.
|
11
|
+
--post-prompt -pp "str" Set the mysh line continuation prompt to "str". $prompt
|
12
|
+
--no-post-prompt -npp Turn off mysh line continuation prompting.
|
13
|
+
--pre-prompt -pr"str" Set the mysh pre prompt to "str". \$w
|
14
|
+
--no-pre-prompt -npr Turn off mysh pre prompting.
|
15
|
+
|
16
|
+
--prompt -p "str" Set the mysh prompt to "str". "mysh"
|
17
|
+
--no-prompt -np Turn off mysh prompting.
|
18
|
+
--quit Quit out of the mysh program.
|
19
|
+
|
20
|
+
* See ?init for more details on the default file loaded.
|
@@ -14,6 +14,7 @@ java - Is the current platform powered by Java?
|
|
14
14
|
term - What terminal is defined by the system, if one is defined.
|
15
15
|
disp - What display is defined by the system, if one is defined.
|
16
16
|
edit - What editor is defined by the system, if one is defined.
|
17
|
+
PID - The process ID of the mysh program.
|
17
18
|
|
18
19
|
path - An easy-to-read, formatted version of the current search path.
|
19
20
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
Help: mysh initialization summary:
|
2
|
+
|
3
|
+
When mysh starts up, it must be initialized and acclimated to its environment.
|
4
|
+
The boot/initialization process of mysh is somewhat modeled after that of the
|
5
|
+
famous bash shell. On startup:
|
6
|
+
|
7
|
+
1 Option values are initialized to their initial, default values.
|
8
|
+
|
9
|
+
2 Process pre-boot command line options: Some command line options are
|
10
|
+
processed early. These are --help, -h, -?, --init, -i, --no-init, and -ni.
|
11
|
+
See Usage above for details on these.
|
12
|
+
|
13
|
+
3 Try to load and execute the mysh_init file. There are three possible files
|
14
|
+
for this role. In priority order they are
|
15
|
+
|
16
|
+
~/mysh_init.mysh,
|
17
|
+
~/mysh_init.rb,
|
18
|
+
~/mysh_init.txt.
|
19
|
+
|
20
|
+
NOTE: If an init file is specified with the --init option, or disabled with
|
21
|
+
the --no-init option, then this step is skipped.
|
22
|
+
|
23
|
+
4 The rest of the command line options are processed at this time.
|
24
|
+
|
25
|
+
It should be noted that in the event of a conflict in settings during the boot
|
26
|
+
process, the last command/option encountered shall prevail. For example if
|
27
|
+
the ~/mysh_init.mysh contains the line:
|
28
|
+
|
29
|
+
\$debug = true
|
30
|
+
|
31
|
+
and the command line has the -nd option, then debug mode will be disabled
|
32
|
+
because the -nd command line option is processed after the mysh_init file.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Help: mysh mls command summary:
|
2
|
+
|
3
|
+
The mls (module list) command is used to provide version information for the
|
4
|
+
loaded ruby modules. The usage template for this command is:
|
5
|
+
|
6
|
+
mysh>mls <mask>
|
7
|
+
|
8
|
+
Where:
|
9
|
+
<mask> is an optional, case-sensitive pattern for filtering out the modules
|
10
|
+
displayed. If omitted, all modules are displayed.
|
11
|
+
|
12
|
+
Examples:
|
13
|
+
|
14
|
+
mysh>mls
|
15
|
+
DidYouMean 1.0.0
|
16
|
+
Gem 2.5.2
|
17
|
+
InArray 0.1.8
|
18
|
+
MiniReadline 0.8.0
|
19
|
+
Mysh 0.5.4
|
20
|
+
VersionLS 0.4.1
|
21
|
+
|
22
|
+
mysh>mls M
|
23
|
+
DidYouMean 1.0.0
|
24
|
+
MiniReadline 0.8.0
|
25
|
+
Mysh 0.5.4
|
@@ -14,7 +14,7 @@ module Mysh
|
|
14
14
|
|
15
15
|
#Execute a help command.
|
16
16
|
def process_command(_args)
|
17
|
-
mysh "load #{(ACTIONS_PATH + 'help/' + @file_name).
|
17
|
+
mysh "load #{(ACTIONS_PATH + 'help/' + @file_name).to_host_spec}"
|
18
18
|
end
|
19
19
|
|
20
20
|
end
|
@@ -25,6 +25,7 @@ module Mysh
|
|
25
25
|
['$', '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
|
+
['%', 'Help on timed command execution.', 'timed.txt' ],
|
28
29
|
['env', 'Help on the show env command.', 'env.txt' ],
|
29
30
|
['ruby', 'Help on the show ruby command.', 'ruby.txt' ],
|
30
31
|
['math', 'Help on math functions.', 'math.txt' ],
|
@@ -32,10 +33,14 @@ module Mysh
|
|
32
33
|
['=', 'Help on ruby expressions.', 'expr.txt' ],
|
33
34
|
['quick', 'Help on quick commands.', 'quick.txt' ],
|
34
35
|
['gls', 'Help on gls internal mysh command.', 'gls.txt' ],
|
36
|
+
['mls', 'Help on mls internal mysh command.', 'mls.txt' ],
|
35
37
|
['!', 'Help on the history command.', 'history.txt'],
|
36
38
|
['history', 'Help on the history command.', 'history.txt'],
|
37
39
|
['kbd', 'Help on mysh keyboard mapping.', 'kbd.txt' ],
|
38
40
|
['{{', 'Help on mysh handlebars.', 'hbar.txt' ],
|
41
|
+
['init', 'Help on mysh initialization.', 'init.txt' ],
|
42
|
+
['args', 'Help on mysh command arguments.', 'args.txt' ],
|
43
|
+
['types', 'Help on mysh file types.', 'types.txt' ],
|
39
44
|
['help', 'This help on the help command.', 'h_o_h.txt' ],
|
40
45
|
['?', 'This help on the help command.', 'h_o_h.txt' ]
|
41
46
|
]
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Help: mysh timed command summary:
|
2
|
+
|
3
|
+
Any command starting with a first character of % will be timed by mysh. This
|
4
|
+
timing occurs in real time at the accuracy of the host timing facilities
|
5
|
+
accessed by Ruby. No accounting for system access or other tasks is made.
|
6
|
+
|
7
|
+
Examples:
|
8
|
+
|
9
|
+
mysh>%say hello world
|
10
|
+
hello world
|
11
|
+
Elapsed execution time = 0.000 seconds.
|
12
|
+
|
13
|
+
mysh>%ls
|
14
|
+
CODE_OF_CONDUCT.md LICENSE.txt lib pkg samples
|
15
|
+
Gemfile README.md mysh.gemspec rakefile.rb tests
|
16
|
+
Gemfile.lock bin mysh.reek reek.txt
|
17
|
+
Elapsed execution time = 0.047 seconds.
|
18
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Help: mysh supported file types.
|
2
|
+
|
3
|
+
The mysh shell has direct support for three types of external files. These are
|
4
|
+
mysh shell scripts, Ruby source files, and augmented text files
|
5
|
+
|
6
|
+
1) The mysh shell scripts are identified by the ".mysh" file suffix. These
|
7
|
+
files contain mysh commands and are interpreted as if typed at the command
|
8
|
+
prompt by the user.
|
9
|
+
|
10
|
+
2) The Ruby source files are just that, Ruby code that is loaded into mysh and
|
11
|
+
executed in the mysh context. These have access to the full power of the
|
12
|
+
Ruby Language system.
|
13
|
+
|
14
|
+
3) The augmented text files are simple text files augmented with support for
|
15
|
+
mysh shell variables ($$var) and embedded code {\{ Ruby code goes here }}
|
16
|
+
|
17
|
+
This help file is an example of an augmented text file.
|
18
|
+
|
@@ -27,6 +27,8 @@ $$post_prompt The prompt used when a line is continued with a trailing \\
|
|
27
27
|
$$pre_prompt A prompt string displayed before the actual command prompt.
|
28
28
|
Delete the pre_prompt variable to disable pre-prompting.
|
29
29
|
$$prompt The user prompt.
|
30
|
+
$$r The location of the Ruby interpreter.
|
31
|
+
$$s The location of the host command processor.
|
30
32
|
$$t The current time.
|
31
33
|
$$time_fmt The format for the time: "%H:%M". ie: 20:11
|
32
34
|
$$u The current user.
|
@@ -56,7 +56,7 @@ module Mysh
|
|
56
56
|
end
|
57
57
|
|
58
58
|
#Add the history commands to the library.
|
59
|
-
desc = 'Display the mysh command history. See ?! for more
|
59
|
+
desc = 'Display the mysh command history. See ?! for more.'
|
60
60
|
COMMANDS.add_action(HistoryCommand.new('history <arg>', desc))
|
61
61
|
#The history command action object.
|
62
62
|
HISTORY_COMMAND = HistoryCommand.new('!<arg>', desc)
|
@@ -2,12 +2,11 @@
|
|
2
2
|
|
3
3
|
require 'vls'
|
4
4
|
|
5
|
-
#* mysh/internal/actions/
|
5
|
+
#* mysh/internal/actions/mls.rb -- The mysh module ls command.
|
6
6
|
module Mysh
|
7
7
|
|
8
|
-
#Add the
|
9
|
-
desc = 'Display
|
10
|
-
'have version info.'
|
8
|
+
#Add the mls command to the library.
|
9
|
+
desc = 'Display modules with version info. See ?mls for more.'
|
11
10
|
|
12
11
|
action = lambda do |input|
|
13
12
|
filter = input.args[0] || /./
|
@@ -20,5 +19,5 @@ module Mysh
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
COMMANDS.add_action(Action.new('
|
22
|
+
COMMANDS.add_action(Action.new('mls <mask>', desc, &action))
|
24
23
|
end
|
@@ -19,19 +19,22 @@ module Mysh
|
|
19
19
|
#<br>Endemic Code Smells
|
20
20
|
#* :reek:UtilityFunction
|
21
21
|
def info
|
22
|
-
[["
|
23
|
-
["
|
22
|
+
[["about", Mysh::SUMMARY],
|
23
|
+
["version", Mysh::VERSION],
|
24
|
+
["init file", $mysh_init_file.to_host_spec],
|
24
25
|
["user", ENV['USER']],
|
25
|
-
["home", (ENV['HOME'] || "").
|
26
|
-
["name", $PROGRAM_NAME.
|
27
|
-
["os shell", (ENV['SHELL'] || ENV['ComSpec'] || "").
|
26
|
+
["home", (ENV['HOME'] || "").to_host_spec],
|
27
|
+
["name", $PROGRAM_NAME.to_host_spec],
|
28
|
+
["os shell", (ENV['SHELL'] || ENV['ComSpec'] || "").to_host_spec],
|
28
29
|
["host", ENV['HOSTNAME'] || ENV['COMPUTERNAME']],
|
29
30
|
["os", ENV['OS']],
|
30
31
|
["platform", MiniReadline::TERM_PLATFORM],
|
31
32
|
["java?", MiniReadline::TERM_JAVA ? true : false],
|
32
33
|
["term", ENV['TERM']],
|
33
34
|
["disp", ENV['DISPLAY']],
|
34
|
-
["edit", ENV['EDITOR']]
|
35
|
+
["edit", ENV['EDITOR']],
|
36
|
+
["PID", $PROCESS_ID]
|
37
|
+
]
|
35
38
|
end
|
36
39
|
|
37
40
|
#Get the path.
|
@@ -19,7 +19,7 @@ module Mysh
|
|
19
19
|
#<br>Endemic Code Smells
|
20
20
|
#* :reek:UtilityFunction
|
21
21
|
def info
|
22
|
-
[["location", RbConfig.ruby.
|
22
|
+
[["location", RbConfig.ruby.to_host_spec],
|
23
23
|
["description", RUBY_DESCRIPTION],
|
24
24
|
["version", RUBY_VERSION],
|
25
25
|
["jversion", (JRUBY_VERSION rescue nil)],
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
#* mysh/internal/
|
3
|
+
#* mysh/internal/to_host_spec.rb -- mysh internal file name beauty treatments.
|
4
4
|
class String
|
5
5
|
|
6
6
|
#Make the file name fit the local system.
|
7
|
-
def
|
7
|
+
def to_host_spec
|
8
8
|
self.dress_up_slashes
|
9
9
|
.dress_up_quotes
|
10
10
|
end
|
@@ -19,4 +19,8 @@ class String
|
|
19
19
|
self[' '] ? "\"#{self}\"" : self
|
20
20
|
end
|
21
21
|
|
22
|
+
#Make the file name fit the standard notation.
|
23
|
+
def to_std_spec
|
24
|
+
self.gsub("\\", "/")
|
25
|
+
end
|
22
26
|
end
|
data/lib/mysh/shell_variables.rb
CHANGED
@@ -17,12 +17,13 @@ module Mysh
|
|
17
17
|
MNV[:pre_prompt] = "$w"
|
18
18
|
|
19
19
|
MNV[:d] = "{{ Time.now.strftime(MNV[:date_fmt]) }}"
|
20
|
-
MNV[:h] = "{{ ENV['HOME'].
|
20
|
+
MNV[:h] = "{{ ENV['HOME'].to_host_spec }}"
|
21
|
+
MNV[:r] = "{{ RbConfig.ruby.to_host_spec }}"
|
22
|
+
MNV[:s] = "{{ (ENV['SHELL'] || ENV['ComSpec'] || '').to_host_spec }}"
|
21
23
|
MNV[:t] = "{{ Time.now.strftime(MNV[:time_fmt]) }}"
|
22
24
|
MNV[:u] = "{{ ENV['USER'] }}"
|
23
|
-
MNV[:w] = "{{ Dir.pwd.
|
25
|
+
MNV[:w] = "{{ Dir.pwd.to_host_spec }}"
|
24
26
|
|
25
27
|
MNV[:date_fmt] = "%Y-%m-%d"
|
26
28
|
MNV[:time_fmt] = "%H:%M"
|
27
|
-
|
28
29
|
end
|
@@ -14,10 +14,11 @@ class String
|
|
14
14
|
|
15
15
|
#Evaluate any variable substitutions in the input.
|
16
16
|
def eval_variables
|
17
|
-
self.gsub(/(\$\$)|(\$[a-z][a-z0-9_]*)/) do |str|
|
17
|
+
self.gsub(/((?<!\\)\$\$)|((?<!\\)\$[a-z][a-z0-9_]*)/) do |str|
|
18
18
|
sym = str[1..-1].to_sym
|
19
19
|
MNV.key?(sym) ? MNV[sym].to_s : str
|
20
|
-
end
|
20
|
+
end.gsub(/\\\$/, "$")
|
21
|
+
|
21
22
|
end
|
22
23
|
|
23
24
|
end
|
data/lib/mysh/version.rb
CHANGED
data/tests/my_shell_tests.rb
CHANGED
@@ -199,7 +199,7 @@ class MyShellTester < Minitest::Test
|
|
199
199
|
assert_equal('@last 45 "is finished" 4 ever', wrapper.cooked)
|
200
200
|
|
201
201
|
assert_equal('@last', wrapper.raw_command)
|
202
|
-
assert_equal('
|
202
|
+
assert_equal('45 "is finished" {{ 2+2 }} ever', wrapper.raw_body)
|
203
203
|
|
204
204
|
assert_equal('@', wrapper.quick_command)
|
205
205
|
assert_equal('last 45 "is finished" {{ 2+2 }} ever', wrapper.quick_body)
|
@@ -213,6 +213,26 @@ class MyShellTester < Minitest::Test
|
|
213
213
|
assert_equal('last 45 "is finished" {{ 2+2 }} ever', wrapper.raw_body)
|
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
|
+
|
217
|
+
Mysh.process_string("$unjust = him")
|
218
|
+
wrapper = Mysh::InputWrapper.new "Lock $unjust up!"
|
219
|
+
|
220
|
+
assert_equal("Lock $unjust up!", wrapper.raw)
|
221
|
+
assert_equal("Lock him up!", wrapper.cooked)
|
222
|
+
assert_equal("Lock", wrapper.raw_command)
|
223
|
+
assert_equal("$unjust up!", wrapper.raw_body)
|
224
|
+
assert_equal("him up!", wrapper.cooked_body)
|
225
|
+
|
226
|
+
wrapper = Mysh::InputWrapper.new "Test"
|
227
|
+
assert_equal("Test", wrapper.raw)
|
228
|
+
assert_equal("Test", wrapper.cooked)
|
229
|
+
assert_equal("Test", wrapper.raw_command)
|
230
|
+
assert_equal("", wrapper.raw_body)
|
231
|
+
assert_equal("", wrapper.cooked_body)
|
232
|
+
end
|
233
|
+
|
234
|
+
def test_to_std_spec
|
235
|
+
assert_equal("test\\foo\\bar.rb".to_std_spec, "test/foo/bar.rb")
|
216
236
|
end
|
217
237
|
|
218
238
|
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.5.
|
4
|
+
version: 0.5.5
|
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-
|
11
|
+
date: 2018-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -180,6 +180,7 @@ files:
|
|
180
180
|
- lib/mysh/internal/actions/exit.rb
|
181
181
|
- lib/mysh/internal/actions/gls.rb
|
182
182
|
- lib/mysh/internal/actions/help.rb
|
183
|
+
- lib/mysh/internal/actions/help/args.txt
|
183
184
|
- lib/mysh/internal/actions/help/env.txt
|
184
185
|
- lib/mysh/internal/actions/help/expr.txt
|
185
186
|
- lib/mysh/internal/actions/help/gls.txt
|
@@ -187,16 +188,21 @@ files:
|
|
187
188
|
- lib/mysh/internal/actions/help/hbar.txt
|
188
189
|
- lib/mysh/internal/actions/help/help.txt
|
189
190
|
- lib/mysh/internal/actions/help/history.txt
|
191
|
+
- lib/mysh/internal/actions/help/init.txt
|
190
192
|
- lib/mysh/internal/actions/help/kbd.txt
|
191
193
|
- lib/mysh/internal/actions/help/math.txt
|
194
|
+
- lib/mysh/internal/actions/help/mls.txt
|
192
195
|
- lib/mysh/internal/actions/help/quick.txt
|
193
196
|
- lib/mysh/internal/actions/help/ruby.txt
|
194
197
|
- lib/mysh/internal/actions/help/show.txt
|
195
198
|
- lib/mysh/internal/actions/help/sub_help.rb
|
199
|
+
- lib/mysh/internal/actions/help/timed.txt
|
200
|
+
- lib/mysh/internal/actions/help/types.txt
|
196
201
|
- lib/mysh/internal/actions/help/usage.txt
|
197
202
|
- lib/mysh/internal/actions/help/vars.txt
|
198
203
|
- lib/mysh/internal/actions/history.rb
|
199
204
|
- lib/mysh/internal/actions/load.rb
|
205
|
+
- lib/mysh/internal/actions/mls.rb
|
200
206
|
- lib/mysh/internal/actions/pwd.rb
|
201
207
|
- lib/mysh/internal/actions/quit.rb
|
202
208
|
- lib/mysh/internal/actions/say.rb
|
@@ -205,8 +211,6 @@ files:
|
|
205
211
|
- lib/mysh/internal/actions/show/ruby.rb
|
206
212
|
- lib/mysh/internal/actions/type.rb
|
207
213
|
- lib/mysh/internal/actions/vars.rb
|
208
|
-
- lib/mysh/internal/actions/vls.rb
|
209
|
-
- lib/mysh/internal/decorate.rb
|
210
214
|
- lib/mysh/internal/format.rb
|
211
215
|
- lib/mysh/internal/format/array.rb
|
212
216
|
- lib/mysh/internal/format/bullets.rb
|
@@ -215,6 +219,7 @@ files:
|
|
215
219
|
- lib/mysh/internal/format/object.rb
|
216
220
|
- lib/mysh/internal/format/string.rb
|
217
221
|
- lib/mysh/internal/manage.rb
|
222
|
+
- lib/mysh/internal/to_file_spec.rb
|
218
223
|
- lib/mysh/pre_processor.rb
|
219
224
|
- lib/mysh/process.rb
|
220
225
|
- lib/mysh/quick.rb
|