mysh 0.6.12 → 0.6.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -3
  3. data/lib/mysh.rb +10 -3
  4. data/lib/mysh/{internal/action.rb → action.rb} +8 -8
  5. data/lib/mysh/{internal/action_pool.rb → action_pool.rb} +8 -8
  6. data/lib/mysh/{internal/actions/command_line.rb → command_line.rb} +10 -10
  7. data/lib/mysh/{internal/actions/command_line → command_line}/debug.rb +0 -0
  8. data/lib/mysh/{internal/actions/command_line → command_line}/history.rb +0 -0
  9. data/lib/mysh/{internal/actions/command_line → command_line}/init.rb +0 -0
  10. data/lib/mysh/{internal/actions/command_line → command_line}/load.rb +0 -0
  11. data/lib/mysh/{internal/actions/command_line → command_line}/pause.rb +0 -0
  12. data/lib/mysh/{internal/actions/command_line → command_line}/post_prompt.rb +0 -0
  13. data/lib/mysh/{internal/actions/command_line → command_line}/pre_prompt.rb +0 -0
  14. data/lib/mysh/{internal/actions/command_line → command_line}/prompt.rb +0 -0
  15. data/lib/mysh/{internal/actions/command_line → command_line}/quit.rb +0 -0
  16. data/lib/mysh/{internal/actions/command_line → command_line}/usage.rb +0 -0
  17. data/lib/mysh/external.rb +3 -4
  18. data/lib/mysh/globalize.rb +5 -7
  19. data/lib/mysh/handlebars.rb +1 -3
  20. data/lib/mysh/handlebars/{string.rb → eval_handlebars.rb} +5 -3
  21. data/lib/mysh/{internal/actions/help → help}/env.txt +0 -0
  22. data/lib/mysh/{internal/actions/help → help}/expr.txt +0 -0
  23. data/lib/mysh/{internal/actions/help → help}/gem.txt +0 -0
  24. data/lib/mysh/{internal/actions/help → help}/gls.txt +0 -0
  25. data/lib/mysh/{internal/actions/help → help}/h_o_h.txt +1 -1
  26. data/lib/mysh/{internal/actions/help → help}/hbar.txt +0 -0
  27. data/lib/mysh/{internal/actions/help → help}/help.txt +0 -0
  28. data/lib/mysh/{internal/actions/help → help}/history.txt +0 -0
  29. data/lib/mysh/{internal/actions/help → help}/init.txt +0 -0
  30. data/lib/mysh/{internal/actions/help → help}/kbd.txt +0 -0
  31. data/lib/mysh/{internal/actions/help → help}/math.txt +0 -0
  32. data/lib/mysh/{internal/actions/help → help}/mls.txt +0 -0
  33. data/lib/mysh/{internal/actions/help → help}/quick.txt +0 -0
  34. data/lib/mysh/{internal/actions/help → help}/ruby.txt +0 -0
  35. data/lib/mysh/{internal/actions/help → help}/show.txt +0 -0
  36. data/lib/mysh/{internal/actions/help → help}/term.txt +0 -0
  37. data/lib/mysh/{internal/actions/help → help}/timed.txt +0 -0
  38. data/lib/mysh/help/type.txt +28 -0
  39. data/lib/mysh/{internal/actions/help → help}/types.txt +0 -0
  40. data/lib/mysh/{internal/actions/help → help}/usage.txt +0 -0
  41. data/lib/mysh/{internal/actions/help → help}/vars.txt +0 -0
  42. data/lib/mysh/input_wrapper.rb +13 -13
  43. data/lib/mysh/internal.rb +20 -8
  44. data/lib/mysh/internal/{actions/cancel.rb → cancel.rb} +0 -0
  45. data/lib/mysh/internal/{actions/cd.rb → cd.rb} +0 -0
  46. data/lib/mysh/internal/{actions/comment.rb → comment.rb} +0 -0
  47. data/lib/mysh/internal/{actions/elapsed.rb → elapsed.rb} +0 -0
  48. data/lib/mysh/internal/{actions/exit.rb → exit.rb} +0 -0
  49. data/lib/mysh/internal/{actions/gls.rb → gls.rb} +0 -0
  50. data/lib/mysh/internal/{actions/help.rb → help.rb} +7 -9
  51. data/lib/mysh/internal/{actions/history.rb → history.rb} +0 -0
  52. data/lib/mysh/internal/load.rb +45 -0
  53. data/lib/mysh/internal/{actions/mls.rb → mls.rb} +0 -0
  54. data/lib/mysh/internal/{actions/pwd.rb → pwd.rb} +0 -0
  55. data/lib/mysh/internal/{actions/say.rb → say.rb} +0 -0
  56. data/lib/mysh/internal/{actions/show.rb → show.rb} +7 -6
  57. data/lib/mysh/internal/{actions/help → support}/sub_help.rb +9 -7
  58. data/lib/mysh/internal/type.rb +38 -0
  59. data/lib/mysh/internal/{actions/vars.rb → vars.rb} +0 -0
  60. data/lib/mysh/{init.rb → load_init_file.rb} +0 -0
  61. data/lib/mysh/process.rb +7 -7
  62. data/lib/mysh/quick.rb +3 -3
  63. data/lib/mysh/shell_variables.rb +6 -3
  64. data/lib/mysh/shell_variables/evaluate.rb +2 -11
  65. data/lib/mysh/{internal/actions/show → show}/env.rb +1 -1
  66. data/lib/mysh/{internal/actions/show → show}/gem.rb +0 -0
  67. data/lib/mysh/{internal/actions/show → show}/ruby.rb +0 -0
  68. data/lib/mysh/{internal/actions/show → show}/term.rb +0 -0
  69. data/lib/mysh/sources/console.rb +3 -2
  70. data/lib/mysh/string_helpers.rb +37 -0
  71. data/lib/mysh/system.rb +2 -2
  72. data/lib/mysh/user_input.rb +4 -7
  73. data/lib/mysh/version.rb +4 -4
  74. data/mysh.gemspec +1 -1
  75. data/tests/my_shell_tests.rb +13 -0
  76. metadata +59 -61
  77. data/lib/mysh/internal/actions/actions_path.rb +0 -15
  78. data/lib/mysh/internal/actions/load.rb +0 -36
  79. data/lib/mysh/internal/actions/type.rb +0 -22
  80. data/lib/mysh/internal/manage.rb +0 -20
  81. data/lib/mysh/internal/to_file_spec.rb +0 -26
  82. data/lib/mysh/pre_processor.rb +0 -11
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
- #* mysh/system.rb -- Support for executing through the system.
3
+ # Support for executing through the system.
4
4
  module Mysh
5
5
 
6
- #Try to execute as a system program.
6
+ # Try to execute as a system program.
7
7
  def self.try_execute_system(input)
8
8
  system(input.raw.preprocess.chomp + "\n") ? :system : :error
9
9
  end
@@ -1,22 +1,20 @@
1
1
  # coding: utf-8
2
2
 
3
- require 'mini_readline'
4
-
5
3
  require_relative 'sources/console'
6
4
  require_relative 'sources/string'
7
5
 
8
6
  require_relative 'sources/smart_auto_complete'
9
7
  require_relative 'sources/parse'
10
8
 
11
- #* mysh/user_input.rb -- Get some text from the user.
9
+ # Get some text from the user.
12
10
  module Mysh
13
11
 
14
- #Get one command from the user.
12
+ # Get one command from the user.
15
13
  def self.get_command(source)
16
14
  get_command_extra(source, source.get_command)
17
15
  end
18
16
 
19
- #Get any continuations of the inputs
17
+ # Get any continuations of the inputs
20
18
  def self.get_command_extra(source, str)
21
19
  if str.start_with?("=") && /\\\s*$/ =~ str
22
20
  get_command_extra(source, $PREMATCH + "\n" + source.get_command_extra(str))
@@ -25,7 +23,7 @@ module Mysh
25
23
  end
26
24
  end
27
25
 
28
- #Get the user input ready.
26
+ # Get the user input ready.
29
27
  def self.input
30
28
  @input ||= MiniReadline::Readline.new(eoi_detect: true,
31
29
  auto_complete: true,
@@ -33,4 +31,3 @@ module Mysh
33
31
  end
34
32
 
35
33
  end
36
-
@@ -1,9 +1,9 @@
1
1
  # coding: utf-8
2
2
 
3
3
  module Mysh
4
- #The version string of MY SHell.
5
- VERSION = "0.6.12"
4
+ # The version string of MY SHell.
5
+ VERSION = "0.6.13".freeze
6
6
 
7
- #A brief summary of this gem.
8
- SUMMARY = "mysh -- a Ruby inspired command line shell."
7
+ # A brief summary of this gem.
8
+ DESCRIPTION = "mysh -- a Ruby inspired command line shell.".freeze
9
9
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Peter Camilleri"]
10
10
  spec.email = ["peter.c.camilleri@gmail.com"]
11
11
 
12
- spec.summary = Mysh::SUMMARY
12
+ spec.summary = Mysh::DESCRIPTION
13
13
  spec.description = "mysh -- a Ruby inspired command shell " +
14
14
  "for CLI and application use."
15
15
  spec.homepage = "https://github.com/PeterCamilleri/mysh"
@@ -11,6 +11,19 @@ class MyShellTester < Minitest::Test
11
11
  #Track mini-test progress.
12
12
  include MinitestVisible
13
13
 
14
+ def test_that_it_has_a_version_number
15
+ refute_nil(::Mysh::VERSION)
16
+ assert(::Mysh::VERSION.frozen?)
17
+ assert(::Mysh::VERSION.is_a?(String))
18
+ assert(/\A\d+\.\d+\.\d+/ =~ ::Mysh::VERSION)
19
+ end
20
+
21
+ def test_that_it_has_a_description
22
+ refute_nil(::Mysh::DESCRIPTION)
23
+ assert(::Mysh::DESCRIPTION.frozen?)
24
+ assert(::Mysh::DESCRIPTION.is_a?(String))
25
+ end
26
+
14
27
  def test_that_module_entities_exists
15
28
  assert_equal(String, Mysh::VERSION.class)
16
29
 
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.12
4
+ version: 0.6.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-08 00:00:00.000000000 Z
11
+ date: 2019-01-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -193,83 +193,81 @@ files:
193
193
  - README.md
194
194
  - bin/mysh
195
195
  - lib/mysh.rb
196
+ - lib/mysh/action.rb
197
+ - lib/mysh/action_pool.rb
198
+ - lib/mysh/command_line.rb
199
+ - lib/mysh/command_line/debug.rb
200
+ - lib/mysh/command_line/history.rb
201
+ - lib/mysh/command_line/init.rb
202
+ - lib/mysh/command_line/load.rb
203
+ - lib/mysh/command_line/pause.rb
204
+ - lib/mysh/command_line/post_prompt.rb
205
+ - lib/mysh/command_line/pre_prompt.rb
206
+ - lib/mysh/command_line/prompt.rb
207
+ - lib/mysh/command_line/quit.rb
208
+ - lib/mysh/command_line/usage.rb
196
209
  - lib/mysh/exceptions.rb
197
210
  - lib/mysh/expression.rb
198
211
  - lib/mysh/expression/lineage.rb
199
212
  - lib/mysh/external.rb
200
213
  - lib/mysh/globalize.rb
201
214
  - lib/mysh/handlebars.rb
202
- - lib/mysh/handlebars/string.rb
203
- - lib/mysh/init.rb
215
+ - lib/mysh/handlebars/eval_handlebars.rb
216
+ - lib/mysh/help/env.txt
217
+ - lib/mysh/help/expr.txt
218
+ - lib/mysh/help/gem.txt
219
+ - lib/mysh/help/gls.txt
220
+ - lib/mysh/help/h_o_h.txt
221
+ - lib/mysh/help/hbar.txt
222
+ - lib/mysh/help/help.txt
223
+ - lib/mysh/help/history.txt
224
+ - lib/mysh/help/init.txt
225
+ - lib/mysh/help/kbd.txt
226
+ - lib/mysh/help/math.txt
227
+ - lib/mysh/help/mls.txt
228
+ - lib/mysh/help/quick.txt
229
+ - lib/mysh/help/ruby.txt
230
+ - lib/mysh/help/show.txt
231
+ - lib/mysh/help/term.txt
232
+ - lib/mysh/help/timed.txt
233
+ - lib/mysh/help/type.txt
234
+ - lib/mysh/help/types.txt
235
+ - lib/mysh/help/usage.txt
236
+ - lib/mysh/help/vars.txt
204
237
  - lib/mysh/input_wrapper.rb
205
238
  - lib/mysh/internal.rb
206
- - lib/mysh/internal/action.rb
207
- - lib/mysh/internal/action_pool.rb
208
- - lib/mysh/internal/actions/actions_path.rb
209
- - lib/mysh/internal/actions/cancel.rb
210
- - lib/mysh/internal/actions/cd.rb
211
- - lib/mysh/internal/actions/command_line.rb
212
- - lib/mysh/internal/actions/command_line/debug.rb
213
- - lib/mysh/internal/actions/command_line/history.rb
214
- - lib/mysh/internal/actions/command_line/init.rb
215
- - lib/mysh/internal/actions/command_line/load.rb
216
- - lib/mysh/internal/actions/command_line/pause.rb
217
- - lib/mysh/internal/actions/command_line/post_prompt.rb
218
- - lib/mysh/internal/actions/command_line/pre_prompt.rb
219
- - lib/mysh/internal/actions/command_line/prompt.rb
220
- - lib/mysh/internal/actions/command_line/quit.rb
221
- - lib/mysh/internal/actions/command_line/usage.rb
222
- - lib/mysh/internal/actions/comment.rb
223
- - lib/mysh/internal/actions/elapsed.rb
224
- - lib/mysh/internal/actions/exit.rb
225
- - lib/mysh/internal/actions/gls.rb
226
- - lib/mysh/internal/actions/help.rb
227
- - lib/mysh/internal/actions/help/env.txt
228
- - lib/mysh/internal/actions/help/expr.txt
229
- - lib/mysh/internal/actions/help/gem.txt
230
- - lib/mysh/internal/actions/help/gls.txt
231
- - lib/mysh/internal/actions/help/h_o_h.txt
232
- - lib/mysh/internal/actions/help/hbar.txt
233
- - lib/mysh/internal/actions/help/help.txt
234
- - lib/mysh/internal/actions/help/history.txt
235
- - lib/mysh/internal/actions/help/init.txt
236
- - lib/mysh/internal/actions/help/kbd.txt
237
- - lib/mysh/internal/actions/help/math.txt
238
- - lib/mysh/internal/actions/help/mls.txt
239
- - lib/mysh/internal/actions/help/quick.txt
240
- - lib/mysh/internal/actions/help/ruby.txt
241
- - lib/mysh/internal/actions/help/show.txt
242
- - lib/mysh/internal/actions/help/sub_help.rb
243
- - lib/mysh/internal/actions/help/term.txt
244
- - lib/mysh/internal/actions/help/timed.txt
245
- - lib/mysh/internal/actions/help/types.txt
246
- - lib/mysh/internal/actions/help/usage.txt
247
- - lib/mysh/internal/actions/help/vars.txt
248
- - lib/mysh/internal/actions/history.rb
249
- - lib/mysh/internal/actions/load.rb
250
- - lib/mysh/internal/actions/mls.rb
251
- - lib/mysh/internal/actions/pwd.rb
252
- - lib/mysh/internal/actions/say.rb
253
- - lib/mysh/internal/actions/show.rb
254
- - lib/mysh/internal/actions/show/env.rb
255
- - lib/mysh/internal/actions/show/gem.rb
256
- - lib/mysh/internal/actions/show/ruby.rb
257
- - lib/mysh/internal/actions/show/term.rb
258
- - lib/mysh/internal/actions/type.rb
259
- - lib/mysh/internal/actions/vars.rb
260
- - lib/mysh/internal/manage.rb
261
- - lib/mysh/internal/to_file_spec.rb
262
- - lib/mysh/pre_processor.rb
239
+ - lib/mysh/internal/cancel.rb
240
+ - lib/mysh/internal/cd.rb
241
+ - lib/mysh/internal/comment.rb
242
+ - lib/mysh/internal/elapsed.rb
243
+ - lib/mysh/internal/exit.rb
244
+ - lib/mysh/internal/gls.rb
245
+ - lib/mysh/internal/help.rb
246
+ - lib/mysh/internal/history.rb
247
+ - lib/mysh/internal/load.rb
248
+ - lib/mysh/internal/mls.rb
249
+ - lib/mysh/internal/pwd.rb
250
+ - lib/mysh/internal/say.rb
251
+ - lib/mysh/internal/show.rb
252
+ - lib/mysh/internal/support/sub_help.rb
253
+ - lib/mysh/internal/type.rb
254
+ - lib/mysh/internal/vars.rb
255
+ - lib/mysh/load_init_file.rb
263
256
  - lib/mysh/process.rb
264
257
  - lib/mysh/quick.rb
265
258
  - lib/mysh/shell_variables.rb
266
259
  - lib/mysh/shell_variables/evaluate.rb
267
260
  - lib/mysh/shell_variables/shell_variable_keeper.rb
268
261
  - lib/mysh/shell_variables/shell_variable_store.rb
262
+ - lib/mysh/show/env.rb
263
+ - lib/mysh/show/gem.rb
264
+ - lib/mysh/show/ruby.rb
265
+ - lib/mysh/show/term.rb
269
266
  - lib/mysh/sources/console.rb
270
267
  - lib/mysh/sources/parse.rb
271
268
  - lib/mysh/sources/smart_auto_complete.rb
272
269
  - lib/mysh/sources/string.rb
270
+ - lib/mysh/string_helpers.rb
273
271
  - lib/mysh/system.rb
274
272
  - lib/mysh/user_input.rb
275
273
  - lib/mysh/version.rb
@@ -1,15 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/actions/actions_path.rb -- A convenient hook to the actions folder.
4
- module Mysh
5
-
6
- #* mysh/internal/actions/actions_path.rb -- A convenient hook to the actions folder.
7
- class Action
8
-
9
- #Capture this folder's name.
10
- ACTIONS_PATH = File.dirname(__FILE__) + "/"
11
-
12
- end
13
-
14
- end
15
-
@@ -1,36 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/actions/load.rb -- The mysh load command.
4
- module Mysh
5
-
6
- #Add the load command to the library.
7
- desc = "Load a ruby program, mysh script, " +
8
- "or text file into the mysh environment."
9
-
10
- action = lambda do |input|
11
- args = input.args
12
- file_name = args.shift
13
-
14
- if file_name
15
- file_ext = File.extname(file_name)
16
-
17
- if file_ext == '.mysh'
18
- Mysh.process_file(file_name)
19
- :internal
20
- elsif file_ext == '.txt'
21
- show_handlebar_file(file_name, binding)
22
- :internal
23
- elsif file_ext == '.rb'
24
- load file_name
25
- :internal
26
- else
27
- fail "Error: Unknown file type: #{file_name.inspect}"
28
- end
29
-
30
- else
31
- fail "Error: A load file must be specified."
32
- end
33
- end
34
-
35
- COMMANDS.add_action(Action.new('load <file>', desc, &action))
36
- end
@@ -1,22 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/actions/type.rb -- The mysh type command.
4
- module Mysh
5
-
6
- #Add the type command to the library.
7
- desc = 'Display a text file with support for optional embedded ' +
8
- 'handlebars and mysh variables.'
9
-
10
- action = lambda do |input|
11
- args = input.args
12
- file_name = args.shift
13
-
14
- if file_name
15
- show_handlebar_file(file_name, binding)
16
- else
17
- fail "A text file must be specified."
18
- end
19
- end
20
-
21
- COMMANDS.add_action(Action.new('type <file>', desc, &action))
22
- end
@@ -1,20 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/manage.rb -- Manage mysh internal commands.
4
- module Mysh
5
-
6
- #Set up the command action pool.
7
- COMMANDS = ActionPool.new("COMMANDS")
8
-
9
- #Try to execute the string as an internal action.
10
- def self.try_execute_internal(input)
11
- unless input.quick_command == ' '
12
- if (action = COMMANDS[input.raw_command])
13
- action.process_command(input)
14
- :internal
15
- end
16
- end
17
- end
18
-
19
- end
20
-
@@ -1,26 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/internal/to_host_spec.rb -- mysh internal file name beauty treatments.
4
- class String
5
-
6
- #Make the file name fit the local system.
7
- def to_host_spec
8
- self.dress_up_slashes
9
- .dress_up_quotes
10
- end
11
-
12
- #Dress up slashes and backslashes.
13
- def dress_up_slashes
14
- MiniTerm.windows? ? self.gsub("/", "\\") : self
15
- end
16
-
17
- #Dress up in quotes if needed.
18
- def dress_up_quotes
19
- self[' '] ? "\"#{self}\"" : self
20
- end
21
-
22
- #Make the file name fit the standard notation.
23
- def to_std_spec
24
- self.gsub("\\", "/")
25
- end
26
- end
@@ -1,11 +0,0 @@
1
- # coding: utf-8
2
-
3
- #* mysh/pre_processor.rb -- The mysh macro/handlebar preprocessor.
4
- class String
5
-
6
- #The mysh string pre-processor stack.
7
- def preprocess(evaluator=$mysh_exec_binding)
8
- self.eval_variables.eval_handlebars(evaluator)
9
- end
10
-
11
- end