mysh 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -12
- data/lib/mysh/exceptions.rb +3 -0
- data/lib/mysh/external.rb +1 -1
- data/lib/mysh/globalize.rb +8 -1
- data/lib/mysh/internal/actions/cancel.rb +10 -0
- data/lib/mysh/internal/actions/command_line/pause.rb +44 -0
- data/lib/mysh/internal/actions/command_line/quit.rb +1 -1
- data/lib/mysh/internal/actions/command_line/usage.rb +1 -1
- data/lib/mysh/internal/actions/command_line.rb +7 -3
- data/lib/mysh/internal/actions/exit.rb +4 -5
- data/lib/mysh/internal/actions/help/sub_help.rb +0 -1
- data/lib/mysh/output_pager.rb +5 -0
- data/lib/mysh/process.rb +4 -1
- data/lib/mysh/shell_variables/evaluate.rb +1 -1
- data/lib/mysh/version.rb +1 -1
- data/tests/my_shell_tests.rb +2 -2
- metadata +4 -4
- data/lib/mysh/internal/actions/help/args.txt +0 -19
- data/lib/mysh/internal/actions/quit.rb +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36d1e9cb65e8e404c9e85ab77e29e1201a2df5f6
|
4
|
+
data.tar.gz: 3e5f058a9f2a8ebbe313fff8983aa328b016652f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9ba17eb0a81ebc7b291767f03f9d56b077b8b82e89593b090fd689eae5acfdce02554b7b8ab0eff9a0359506328bb7a28f49101ac0b9847980d5dec10b075c
|
7
|
+
data.tar.gz: fbb691b11d8daf992f152412bd4dae5b3ebe958c73abfc1f2c759ba0c757443c8bacf19174914057cb95639dcac5c8a417973ff0e02e5bd87ee2ff495b8e872a
|
data/README.md
CHANGED
@@ -130,6 +130,8 @@ Option | Short Form(s)| Description | Default
|
|
130
130
|
--init filename | -i filename | Initialize mysh by loading the specified file. | ~/mysh_init.mysh
|
131
131
|
--no-init | -ni | Do not load a file to initialize mysh.
|
132
132
|
--load filename | -l filename | Load the specified file into the mysh.
|
133
|
+
--pause | | Enable page pauses for long output.
|
134
|
+
--no-pause | | Disable page pauses for long output.
|
133
135
|
--post-prompt "str" | -pp "str" | Set the mysh line continuation prompt to "str". | $prompt
|
134
136
|
--no-post-prompt | -npp | Turn off mysh line continuation prompting.
|
135
137
|
--pre-prompt "str" | -pr "str" | Set the mysh pre prompt to "str". | $w
|
@@ -343,6 +345,25 @@ baz yes
|
|
343
345
|
|
344
346
|
```
|
345
347
|
|
348
|
+
###### Page Pause
|
349
|
+
|
350
|
+
Some commands can generate very lengthy output that can scroll off the top of
|
351
|
+
the screen. to handle this, mysh automatically inserts pauses once per screen.
|
352
|
+
At this point, it displays a prompt and waits for the users to press a key that
|
353
|
+
will determine the action to take. The default message is:
|
354
|
+
|
355
|
+
Press a key, a space, or q:
|
356
|
+
|
357
|
+
The available actions are:
|
358
|
+
|
359
|
+
Key | Action
|
360
|
+
-----------|-----------------------------------------------
|
361
|
+
'q' or "Q" | Stop the long winded command.
|
362
|
+
Space | Add a single line of additional output.
|
363
|
+
Other | Add up to a whole page of additional output.
|
364
|
+
|
365
|
+
This feature is controlled by the $page_pause variable that can be either
|
366
|
+
on or off as well as the --pause and --no-pause command line options.
|
346
367
|
|
347
368
|
#### LOOP
|
348
369
|
|
@@ -439,6 +460,10 @@ $date_fmt | The format for the date: "%Y-%m-%d"
|
|
439
460
|
$debug | Does the shell display additional debugging info (true/false)
|
440
461
|
$h | The home folder's path
|
441
462
|
$name | The name given to this mysh session.
|
463
|
+
$page_height| The page height.
|
464
|
+
$page_msg | The paging message. Default is "Press a key, a space, or q:"
|
465
|
+
$page_pause | Is page pausing enabled?
|
466
|
+
$page_width | The page width.
|
442
467
|
$post_prompt| The prompt used when a line is continued with a trailing \\ character. By default this is the same as the normal prompt.
|
443
468
|
$pre_prompt | A prompt string displayed before the actual command prompt. Delete the pre_prompt variable to disable pre-prompting.
|
444
469
|
$prompt | The user prompt.
|
@@ -649,18 +674,21 @@ Internal commands are recognized by name and are executed by mysh directly. The
|
|
649
674
|
complete list of internal commands is given in the default help command ("?").
|
650
675
|
Some commands, not already covered in other sections include:
|
651
676
|
|
652
|
-
Command
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
677
|
+
Command | Description
|
678
|
+
-----------------|----------------------------------------------------
|
679
|
+
cancel | Cancel the current mysh execution level.
|
680
|
+
cd <dir> | Change directory to the optional <dir> parameter or display the current working directory.
|
681
|
+
exit | Exit out of the mysh.
|
682
|
+
gls <-l> <mask> | Display the loaded ruby gems.
|
683
|
+
help <topic> | Display help information for mysh with an optional topic.
|
684
|
+
history <arg> | Display the mysh command history.
|
685
|
+
load <file> | Load a ruby program, mysh script, or text file into the mysh
|
686
|
+
mls <mask> | Display modules with version info.
|
687
|
+
pwd | Display the current working directory.
|
688
|
+
say <stuff> | Display the text in the command arguments.
|
689
|
+
set <$name>=value| Set/query mysh variables.
|
690
|
+
show <item> | Display information about a part of mysh.
|
691
|
+
type <file> | Display a text file with support for optional embedded handlebars and mysh variables.
|
664
692
|
|
665
693
|
Notes:
|
666
694
|
1. The notation {x} means that x is optional.
|
@@ -904,6 +932,7 @@ application gem uses the following exception classes:
|
|
904
932
|
MyshException # The abstract base exception for mysh.
|
905
933
|
MyshExit # Exit the current mysh processing loop.
|
906
934
|
MyshStopOutput # Stop further output from a verbose command.
|
935
|
+
MyshUsage # Internal: Used by the --help options.
|
907
936
|
|
908
937
|
|
909
938
|
## Contributing
|
data/lib/mysh/exceptions.rb
CHANGED
data/lib/mysh/external.rb
CHANGED
@@ -15,7 +15,7 @@ module Mysh
|
|
15
15
|
|
16
16
|
if ext == '.rb'
|
17
17
|
new_command = "#{RbConfig.ruby} #{input.cooked}"
|
18
|
-
puts "=> #{new_command}" if MNV[:debug].
|
18
|
+
puts "=> #{new_command}" if MNV[:debug].extract_boolean
|
19
19
|
system(new_command)
|
20
20
|
:ruby_exec
|
21
21
|
elsif ext == '.mysh'
|
data/lib/mysh/globalize.rb
CHANGED
@@ -19,16 +19,23 @@ class Object
|
|
19
19
|
def more
|
20
20
|
saved = $stdout
|
21
21
|
|
22
|
-
if MNV[:page_pause].
|
22
|
+
if MNV[:page_pause].extract_boolean
|
23
23
|
$stdout = OutputPager.new if (outer = $stdout.equal?($mysh_out))
|
24
24
|
end
|
25
25
|
|
26
26
|
yield
|
27
|
+
|
27
28
|
rescue MyshStopOutput
|
28
29
|
raise unless outer
|
29
30
|
return
|
31
|
+
|
30
32
|
ensure
|
31
33
|
$stdout = saved
|
32
34
|
end
|
33
35
|
|
36
|
+
#Unwrap one mysh layer.
|
37
|
+
def cancel
|
38
|
+
raise MyshExit
|
39
|
+
end
|
40
|
+
|
34
41
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Mysh
|
4
|
+
|
5
|
+
# The page pause option.
|
6
|
+
class PauseOption < CommandOption
|
7
|
+
|
8
|
+
#Execute the help command line option.
|
9
|
+
#<br>Endemic Code Smells
|
10
|
+
#* :reek:UtilityFunction
|
11
|
+
def post_boot(_args)
|
12
|
+
MNV[:page_pause] = "on"
|
13
|
+
end
|
14
|
+
|
15
|
+
def pre_boot(_args)
|
16
|
+
MNV[:page_pause] = "on"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
#Add the pause command line option to the library.
|
22
|
+
desc = 'Turn on page pauses.'
|
23
|
+
COMMAND_LINE.add_action(PauseOption.new('--pause', desc))
|
24
|
+
|
25
|
+
# The no page pause option.
|
26
|
+
class NoPauseOption < CommandOption
|
27
|
+
|
28
|
+
#Execute the help command line option.
|
29
|
+
#<br>Endemic Code Smells
|
30
|
+
#* :reek:UtilityFunction
|
31
|
+
def post_boot(_args)
|
32
|
+
MNV[:page_pause] = "off"
|
33
|
+
end
|
34
|
+
|
35
|
+
def pre_boot(_args)
|
36
|
+
MNV[:page_pause] = "off"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
#Add the no pause command line option to the library.
|
42
|
+
desc = 'Turn off page pauses.'
|
43
|
+
COMMAND_LINE.add_action(NoPauseOption.new('--no-pause', desc))
|
44
|
+
end
|
@@ -41,12 +41,16 @@ module Mysh
|
|
41
41
|
next_command.send(phase, read_point)
|
42
42
|
end
|
43
43
|
|
44
|
+
rescue MyshUsage
|
45
|
+
HELP["usage"].process_command(nil)
|
46
|
+
exit
|
47
|
+
|
44
48
|
rescue => err
|
45
|
-
|
46
|
-
puts "",
|
49
|
+
more do
|
50
|
+
puts "", err.to_s, ""
|
51
|
+
HELP["usage"].process_command(nil)
|
47
52
|
end
|
48
53
|
|
49
|
-
HELP["usage"].process_command(nil)
|
50
54
|
exit
|
51
55
|
end
|
52
56
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal exit command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#Add the exit command to the library.
|
7
|
-
desc = 'Exit the
|
8
|
-
action = lambda {|_input| raise MyshExit}
|
6
|
+
# Add the exit command to the library.
|
7
|
+
desc = 'Exit out of the mysh.'
|
9
8
|
|
10
|
-
COMMANDS.add_action(Action.new('exit', desc
|
9
|
+
COMMANDS.add_action(Action.new('exit', desc) {|_input| exit })
|
11
10
|
end
|
@@ -39,7 +39,6 @@ module Mysh
|
|
39
39
|
['kbd', 'Help on mysh keyboard mapping.', 'kbd.txt' ],
|
40
40
|
['{{', 'Help on mysh handlebars.', 'hbar.txt' ],
|
41
41
|
['init', 'Help on mysh initialization.', 'init.txt' ],
|
42
|
-
['args', 'Help on mysh command arguments.', 'args.txt' ],
|
43
42
|
['types', 'Help on mysh file types.', 'types.txt' ],
|
44
43
|
['help', 'This help on the help command.', 'h_o_h.txt' ],
|
45
44
|
['?', 'This help on the help command.', 'h_o_h.txt' ]
|
data/lib/mysh/output_pager.rb
CHANGED
data/lib/mysh/process.rb
CHANGED
@@ -30,9 +30,12 @@ module Mysh
|
|
30
30
|
def self.execute_a_command(source)
|
31
31
|
try_execute_command(get_command(source))
|
32
32
|
|
33
|
+
rescue MyshExit
|
34
|
+
raise
|
35
|
+
|
33
36
|
rescue Interrupt, StandardError, ScriptError => err
|
34
37
|
puts "Error #{err.class}: #{err}"
|
35
|
-
puts err.backtrace if MNV[:debug].
|
38
|
+
puts err.backtrace if MNV[:debug].extract_boolean || defined?(MiniTest)
|
36
39
|
end
|
37
40
|
|
38
41
|
#Try to execute a single line of input. Does not handle exceptions.
|
data/lib/mysh/version.rb
CHANGED
data/tests/my_shell_tests.rb
CHANGED
@@ -28,7 +28,7 @@ class MyShellTester < Minitest::Test
|
|
28
28
|
|
29
29
|
def test_for_internal_commands
|
30
30
|
assert(Mysh::COMMANDS['exit'], "The exit command is missing.")
|
31
|
-
assert(Mysh::COMMANDS['
|
31
|
+
assert(Mysh::COMMANDS['cancel'], "The cancel command is missing.")
|
32
32
|
|
33
33
|
assert(Mysh::COMMANDS['history'], "The history command is missing.")
|
34
34
|
assert(Mysh::COMMANDS['!<arg>'], "The ! command is missing.")
|
@@ -150,7 +150,7 @@ class MyShellTester < Minitest::Test
|
|
150
150
|
assert(MNV.key?(:test), "MNV[:test] should exist.")
|
151
151
|
|
152
152
|
Mysh.try_execute_command("set $test = off")
|
153
|
-
assert_equal(false, MNV[:test].
|
153
|
+
assert_equal(false, MNV[:test].extract_boolean)
|
154
154
|
assert_equal("off", MNV[:test])
|
155
155
|
assert(MNV.key?(:test), "MNV[:test] should exist.")
|
156
156
|
|
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.6.
|
4
|
+
version: 0.6.6
|
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-12-
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -165,11 +165,13 @@ files:
|
|
165
165
|
- lib/mysh/internal/action.rb
|
166
166
|
- lib/mysh/internal/action_pool.rb
|
167
167
|
- lib/mysh/internal/actions/actions_path.rb
|
168
|
+
- lib/mysh/internal/actions/cancel.rb
|
168
169
|
- lib/mysh/internal/actions/cd.rb
|
169
170
|
- lib/mysh/internal/actions/command_line.rb
|
170
171
|
- lib/mysh/internal/actions/command_line/debug.rb
|
171
172
|
- lib/mysh/internal/actions/command_line/init.rb
|
172
173
|
- lib/mysh/internal/actions/command_line/load.rb
|
174
|
+
- lib/mysh/internal/actions/command_line/pause.rb
|
173
175
|
- lib/mysh/internal/actions/command_line/post_prompt.rb
|
174
176
|
- lib/mysh/internal/actions/command_line/pre_prompt.rb
|
175
177
|
- lib/mysh/internal/actions/command_line/prompt.rb
|
@@ -180,7 +182,6 @@ files:
|
|
180
182
|
- lib/mysh/internal/actions/exit.rb
|
181
183
|
- lib/mysh/internal/actions/gls.rb
|
182
184
|
- lib/mysh/internal/actions/help.rb
|
183
|
-
- lib/mysh/internal/actions/help/args.txt
|
184
185
|
- lib/mysh/internal/actions/help/env.txt
|
185
186
|
- lib/mysh/internal/actions/help/expr.txt
|
186
187
|
- lib/mysh/internal/actions/help/gls.txt
|
@@ -204,7 +205,6 @@ files:
|
|
204
205
|
- lib/mysh/internal/actions/load.rb
|
205
206
|
- lib/mysh/internal/actions/mls.rb
|
206
207
|
- lib/mysh/internal/actions/pwd.rb
|
207
|
-
- lib/mysh/internal/actions/quit.rb
|
208
208
|
- lib/mysh/internal/actions/say.rb
|
209
209
|
- lib/mysh/internal/actions/show.rb
|
210
210
|
- lib/mysh/internal/actions/show/env.rb
|
@@ -1,19 +0,0 @@
|
|
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
|
-
--prompt -p "str" Set the mysh prompt to "str". "mysh"
|
16
|
-
--no-prompt -np Turn off mysh prompting.
|
17
|
-
--quit Quit out of the mysh program.
|
18
|
-
|
19
|
-
* See ?init for more details on the default file loaded.
|