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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cffedfff55f5d5d4d26d6dc3f9b9871b2af5b9e6
4
- data.tar.gz: 15dd0fe9b7a5b885144f6b635494755e03979f35
3
+ metadata.gz: 36d1e9cb65e8e404c9e85ab77e29e1201a2df5f6
4
+ data.tar.gz: 3e5f058a9f2a8ebbe313fff8983aa328b016652f
5
5
  SHA512:
6
- metadata.gz: 88e80a96bab121558084c7052140ce3eb66a48158c0e6f8daf565dc50293f320176c80f90278e1b0e12526a6dcbfb3d1644290503ceb70ee486f2fff29d4f921
7
- data.tar.gz: 0d659db5efd3333f227311636712f87dd989a350c3dc2594085c91c021016e0a59ee917b77e4ef190d6d3d0286e2d2a554ca44927e117c6ea0f8566de41c54e1
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 | Description
653
- ---------------|----------------------------------------------------
654
- cd {dir} | Change directory to the optional dir parameter and then display the current working directory.
655
- exit | Exit mysh.
656
- gls {-l} {mask}| Display the loaded ruby gems. See ?gls for more.
657
- history {index}| The mysh command history. If an index is specified, get the command with that index value.
658
- load file | Load a ruby program, mysh script, or text file into the mysh environment.
659
- mls {mask} | Display modules with version info. See ?mls for more.
660
- pwd | Display the current working directory.
661
- quit | Exit mysh.
662
- say <stuff> | Display the text in the command arguments.
663
- type file | Display a text file with support for optional embedded handlebars and mysh variables.
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
@@ -8,3 +8,6 @@ class MyshExit < MyshException; end
8
8
 
9
9
  # Stop further output from a verbose command.
10
10
  class MyshStopOutput < MyshException; end
11
+
12
+ # Display usage info and exit.
13
+ class MyshUsage < MyshException; end
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].extract_mysh_types
18
+ puts "=> #{new_command}" if MNV[:debug].extract_boolean
19
19
  system(new_command)
20
20
  :ruby_exec
21
21
  elsif ext == '.mysh'
@@ -19,16 +19,23 @@ class Object
19
19
  def more
20
20
  saved = $stdout
21
21
 
22
- if MNV[:page_pause].extract_mysh_types
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,10 @@
1
+ # coding: utf-8
2
+
3
+ # The mysh internal cancel command.
4
+ module Mysh
5
+
6
+ # Add the cancel command to the library.
7
+ desc = 'Cancel the current mysh level.'
8
+
9
+ COMMANDS.add_action(Action.new('cancel', desc) {|_input| cancel})
10
+ 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
@@ -14,6 +14,6 @@ module Mysh
14
14
  end
15
15
 
16
16
  #Add the quit command line option to the library.
17
- desc = 'Quit out of the mysh program.'
17
+ desc = "Exit a nested mysh file or command."
18
18
  COMMAND_LINE.add_action(QuitOption.new('--quit', desc))
19
19
  end
@@ -8,7 +8,7 @@ module Mysh
8
8
 
9
9
  #Execute the help command line option. (Punt to error handler with no msg)
10
10
  def pre_boot(_args)
11
- raise ""
11
+ raise MyshUsage
12
12
  end
13
13
 
14
14
  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
- unless (msg = err.to_s).empty?
46
- puts "", msg, ""
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
- #* mysh/internal/actions/exit.rb -- The mysh internal exit command.
3
+ # The mysh internal exit command.
4
4
  module Mysh
5
5
 
6
- #Add the exit command to the library.
7
- desc = 'Exit the current mysh level.'
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, &action))
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' ]
@@ -20,6 +20,11 @@ class OutputPager
20
20
  end
21
21
  end
22
22
 
23
+ # Write out an object as a string.
24
+ def <<(obj)
25
+ write(obj.to_s)
26
+ end
27
+
23
28
  private
24
29
 
25
30
  # Write out a simple string with no embedded new-lines.
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].extract_mysh_types || defined?(MiniTest)
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.
@@ -4,7 +4,7 @@
4
4
  class String
5
5
 
6
6
  #Extract common mysh data from this string.
7
- def extract_mysh_types
7
+ def extract_boolean
8
8
  if self =~ /\A(false|no|off)\z/i
9
9
  false
10
10
  else
data/lib/mysh/version.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Mysh
4
4
  #The version string of MY SHell.
5
- VERSION = "0.6.5"
5
+ VERSION = "0.6.6"
6
6
 
7
7
  #A brief summary of this gem.
8
8
  SUMMARY = "mysh -- a Ruby inspired command line shell."
@@ -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['quit'], "The quit command is missing.")
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].extract_mysh_types)
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.5
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-01 00:00:00.000000000 Z
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.
@@ -1,10 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/actions/quit.rb -- The mysh internal quit command.
4
- module Mysh
5
-
6
- #Add the quit command to the library.
7
- desc = 'Quit out of the mysh.'
8
-
9
- COMMANDS.add_action(Action.new('quit', desc) {|_input| exit })
10
- end