mysh 0.6.12 → 0.6.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -3
- data/lib/mysh.rb +11 -3
- data/lib/mysh/{internal/action.rb → action.rb} +8 -8
- data/lib/mysh/{internal/action_pool.rb → action_pool.rb} +8 -8
- data/lib/mysh/{internal/actions/command_line.rb → command_line.rb} +10 -10
- data/lib/mysh/{internal/actions/command_line → command_line}/debug.rb +9 -11
- data/lib/mysh/{internal/actions/command_line → command_line}/history.rb +0 -0
- data/lib/mysh/{internal/actions/command_line → command_line}/init.rb +8 -8
- data/lib/mysh/{internal/actions/command_line → command_line}/load.rb +5 -5
- data/lib/mysh/{internal/actions/command_line → command_line}/pause.rb +6 -8
- data/lib/mysh/{internal/actions/command_line → command_line}/post_prompt.rb +10 -12
- data/lib/mysh/{internal/actions/command_line → command_line}/pre_prompt.rb +10 -12
- data/lib/mysh/{internal/actions/command_line → command_line}/prompt.rb +9 -10
- data/lib/mysh/command_line/quit.rb +19 -0
- data/lib/mysh/{internal/actions/command_line → command_line}/usage.rb +4 -4
- data/lib/mysh/external.rb +3 -4
- data/lib/mysh/globalize.rb +5 -14
- data/lib/mysh/handlebars.rb +1 -3
- data/lib/mysh/handlebars/{string.rb → eval_handlebars.rb} +5 -3
- data/lib/mysh/{internal/actions/help → help}/env.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/expr.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/gem.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/gls.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/h_o_h.txt +1 -1
- data/lib/mysh/{internal/actions/help → help}/hbar.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/help.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/history.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/init.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/kbd.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/math.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/mls.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/quick.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/ruby.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/show.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/term.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/timed.txt +0 -0
- data/lib/mysh/help/type.txt +28 -0
- data/lib/mysh/{internal/actions/help → help}/types.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/usage.txt +0 -0
- data/lib/mysh/{internal/actions/help → help}/vars.txt +4 -4
- data/lib/mysh/input_wrapper.rb +13 -13
- data/lib/mysh/internal.rb +20 -8
- data/lib/mysh/internal/{actions/cancel.rb → cancel.rb} +0 -0
- data/lib/mysh/internal/{actions/cd.rb → cd.rb} +2 -2
- data/lib/mysh/internal/{actions/comment.rb → comment.rb} +2 -2
- data/lib/mysh/internal/{actions/elapsed.rb → elapsed.rb} +2 -2
- data/lib/mysh/internal/{actions/exit.rb → exit.rb} +0 -0
- data/lib/mysh/internal/{actions/gls.rb → gls.rb} +6 -7
- data/lib/mysh/internal/{actions/help.rb → help.rb} +7 -9
- data/lib/mysh/internal/{actions/history.rb → history.rb} +10 -9
- data/lib/mysh/internal/load.rb +45 -0
- data/lib/mysh/internal/{actions/mls.rb → mls.rb} +2 -2
- data/lib/mysh/internal/{actions/pwd.rb → pwd.rb} +1 -1
- data/lib/mysh/internal/{actions/say.rb → say.rb} +1 -1
- data/lib/mysh/internal/{actions/show.rb → show.rb} +7 -6
- data/lib/mysh/internal/{actions/help → support}/sub_help.rb +9 -7
- data/lib/mysh/internal/type.rb +38 -0
- data/lib/mysh/internal/{actions/vars.rb → vars.rb} +8 -8
- data/lib/mysh/{init.rb → load_init_file.rb} +0 -0
- data/lib/mysh/process.rb +7 -7
- data/lib/mysh/quick.rb +3 -3
- data/lib/mysh/shell_variables.rb +6 -4
- data/lib/mysh/shell_variables/evaluate.rb +2 -11
- data/lib/mysh/shell_variables/shell_variable_keeper.rb +6 -7
- data/lib/mysh/shell_variables/shell_variable_store.rb +13 -14
- data/lib/mysh/{internal/actions/show → show}/env.rb +1 -1
- data/lib/mysh/{internal/actions/show → show}/gem.rb +0 -0
- data/lib/mysh/{internal/actions/show → show}/ruby.rb +0 -0
- data/lib/mysh/{internal/actions/show → show}/term.rb +0 -0
- data/lib/mysh/sources/console.rb +3 -2
- data/lib/mysh/sources/parse.rb +7 -10
- data/lib/mysh/sources/smart_auto_complete.rb +5 -5
- data/lib/mysh/sources/string.rb +6 -6
- data/lib/mysh/string_helpers.rb +37 -0
- data/lib/mysh/system.rb +2 -2
- data/lib/mysh/user_input.rb +4 -7
- data/lib/mysh/version.rb +4 -4
- data/mysh.gemspec +4 -4
- data/tests/my_shell_tests.rb +12 -3
- metadata +79 -81
- data/lib/mysh/internal/actions/actions_path.rb +0 -15
- data/lib/mysh/internal/actions/command_line/quit.rb +0 -19
- data/lib/mysh/internal/actions/load.rb +0 -36
- data/lib/mysh/internal/actions/type.rb +0 -22
- data/lib/mysh/internal/manage.rb +0 -20
- data/lib/mysh/internal/to_file_spec.rb +0 -26
- data/lib/mysh/pre_processor.rb +0 -11
File without changes
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal cd command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#Add the cd command to the library.
|
6
|
+
# Add the cd command to the library.
|
7
7
|
desc = 'Change directory to the optional <dir> parameter ' +
|
8
8
|
'or display the current working directory.'
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# A mysh internal comment.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#Add comments to the library.
|
6
|
+
# Add comments to the library.
|
7
7
|
desc = 'A mysh comment. No action taken'
|
8
8
|
action = lambda {|_input| :internal}
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal elapsed command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#Add the elapsed commands to the library.
|
6
|
+
# Add the elapsed commands to the library.
|
7
7
|
desc = 'Execute a command and then display the elapsed time. See ?% for more.'
|
8
8
|
|
9
9
|
action = lambda do |input|
|
File without changes
|
@@ -1,18 +1,18 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh gls (gem ls) command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
|
6
|
+
# The mysh gls (gem ls) command.
|
7
7
|
class GlsCommand < Action
|
8
8
|
|
9
|
-
#Set up this command.
|
9
|
+
# Set up this command.
|
10
10
|
def initialize(*args)
|
11
11
|
super
|
12
12
|
@report = @mask = @specs = nil
|
13
13
|
end
|
14
14
|
|
15
|
-
#Execute the gls command.
|
15
|
+
# Execute the gls command.
|
16
16
|
def process_command(input)
|
17
17
|
process_args(input.args)
|
18
18
|
gather_gems
|
@@ -57,9 +57,8 @@ module Mysh
|
|
57
57
|
report.puts_format_output_bullets
|
58
58
|
end
|
59
59
|
|
60
|
-
#Get detailed information on a gem specification.
|
61
|
-
|
62
|
-
#* :reek:UtilityFunction
|
60
|
+
# Get detailed information on a gem specification.
|
61
|
+
# Endemic Code Smells :reek:UtilityFunction
|
63
62
|
def info(spec)
|
64
63
|
[["name", spec.name],
|
65
64
|
["version", spec.version],
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal help command.
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
# Help action pool of topics.
|
@@ -21,12 +21,11 @@ module Mysh
|
|
21
21
|
|
22
22
|
HELP = ActionPool.new("HELP", default)
|
23
23
|
|
24
|
-
|
24
|
+
# The mysh internal help command.
|
25
25
|
class HelpCommand < Action
|
26
26
|
|
27
|
-
#Execute a help command by routing it to a sub-command.
|
28
|
-
|
29
|
-
#* :reek:UtilityFunction
|
27
|
+
# Execute a help command by routing it to a sub-command.
|
28
|
+
# Endemic Code Smells :reek:UtilityFunction
|
30
29
|
def process_command(input)
|
31
30
|
args = input.args
|
32
31
|
HELP[args[0] || ""].process_command(args)
|
@@ -37,12 +36,11 @@ module Mysh
|
|
37
36
|
# The base help command.
|
38
37
|
desc = 'Display help information for mysh with an optional topic. See ?? for more.'
|
39
38
|
COMMANDS.add_action(HelpCommand.new('help <topic>', desc))
|
39
|
+
|
40
40
|
#The help command action object.
|
41
41
|
HELP_COMMAND = HelpCommand.new('?<topic>', desc)
|
42
42
|
COMMANDS.add_action(HELP_COMMAND)
|
43
43
|
end
|
44
44
|
|
45
|
-
|
46
|
-
|
47
|
-
#Load up the extra help actions!
|
48
|
-
Dir[Mysh::Action::ACTIONS_PATH + 'help/*.rb'].each {|file| require file }
|
45
|
+
# Load in support for help sub-topics
|
46
|
+
require_relative 'support/sub_help'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal history command.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
|
6
|
+
# The mysh internal history command.
|
7
7
|
class HistoryCommand < Action
|
8
8
|
|
9
9
|
#Set up this command.
|
@@ -12,11 +12,11 @@ module Mysh
|
|
12
12
|
@args = @history = nil
|
13
13
|
end
|
14
14
|
|
15
|
-
#Execute the history command.
|
15
|
+
# Execute the history command.
|
16
16
|
def process_command(input)
|
17
17
|
@args, @history = input.args, Mysh.input.history
|
18
18
|
|
19
|
-
#The history command should not be part of the history.
|
19
|
+
# The history command should not be part of the history.
|
20
20
|
@history.pop
|
21
21
|
|
22
22
|
pull_index || clear_history || show_history
|
@@ -24,7 +24,7 @@ module Mysh
|
|
24
24
|
|
25
25
|
private
|
26
26
|
|
27
|
-
#Deal with history index arguments
|
27
|
+
# Deal with history index arguments
|
28
28
|
def pull_index
|
29
29
|
index = @args[0].to_i
|
30
30
|
|
@@ -35,7 +35,7 @@ module Mysh
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
#Clear the history buffer.
|
38
|
+
# Clear the history buffer.
|
39
39
|
def clear_history
|
40
40
|
if @args[0] == 'clear'
|
41
41
|
@history.clear
|
@@ -44,7 +44,7 @@ module Mysh
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
#Just show the history.
|
47
|
+
# Just show the history.
|
48
48
|
def show_history
|
49
49
|
pattern = Regexp.new(@args[0] || /./)
|
50
50
|
|
@@ -55,10 +55,11 @@ module Mysh
|
|
55
55
|
|
56
56
|
end
|
57
57
|
|
58
|
-
#Add the history commands to the library.
|
58
|
+
# Add the history commands to the library.
|
59
59
|
desc = 'Display the mysh command history. See ?! for more.'
|
60
60
|
COMMANDS.add_action(HistoryCommand.new('history <arg>', desc))
|
61
|
-
|
61
|
+
|
62
|
+
# The history command action object.
|
62
63
|
HISTORY_COMMAND = HistoryCommand.new('!<arg>', desc)
|
63
64
|
COMMANDS.add_action(HISTORY_COMMAND)
|
64
65
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# The mysh load command.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
# Add the load command to the library.
|
7
|
+
desc = "Load ruby programs, mysh scripts, " +
|
8
|
+
"or text files into the mysh environment."
|
9
|
+
|
10
|
+
action = lambda do |input|
|
11
|
+
count = 0
|
12
|
+
args = input.args
|
13
|
+
|
14
|
+
args.each do |file_name|
|
15
|
+
puts file_name if args.length > 1
|
16
|
+
Mysh.load_a_file(file_name)
|
17
|
+
count += 1
|
18
|
+
end
|
19
|
+
|
20
|
+
if count > 0
|
21
|
+
:internal
|
22
|
+
else
|
23
|
+
fail "Error: A load file must be specified."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Load a single file.
|
28
|
+
def self.load_a_file(file_name)
|
29
|
+
case File.extname(file_name)
|
30
|
+
when '.mysh'
|
31
|
+
Mysh.process_file(file_name)
|
32
|
+
:internal
|
33
|
+
when '.txt'
|
34
|
+
show_handlebar_file(file_name, binding)
|
35
|
+
:internal
|
36
|
+
when '.rb'
|
37
|
+
load file_name
|
38
|
+
:internal
|
39
|
+
else
|
40
|
+
fail "Error: Unknown file type: #{file_name.inspect}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
COMMANDS.add_action(Action.new('load <files>', desc, &action))
|
45
|
+
end
|
@@ -2,10 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'vls'
|
4
4
|
|
5
|
-
|
5
|
+
# The mysh module ls command.
|
6
6
|
module Mysh
|
7
7
|
|
8
|
-
#Add the mls command to the library.
|
8
|
+
# Add the mls command to the library.
|
9
9
|
desc = 'Display modules with version info. See ?mls for more.'
|
10
10
|
|
11
11
|
action = lambda do |input|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal show command.
|
4
4
|
module Mysh
|
5
5
|
|
6
6
|
# The working message for long duration processing.
|
7
7
|
WORKING = "Working...\r"
|
8
8
|
|
9
|
-
#Show items.
|
9
|
+
# Show items.
|
10
10
|
default = Action.new do |input|
|
11
11
|
puts "No show data found for #{input.raw.inspect}. See ?@ for more."
|
12
12
|
end
|
13
13
|
|
14
14
|
SHOW = ActionPool.new("SHOW", default)
|
15
15
|
|
16
|
-
#The shared description.
|
16
|
+
# The shared description.
|
17
17
|
desc = "Display information about a part of mysh. See ?@ for more."
|
18
18
|
|
19
19
|
action = lambda do |input|
|
@@ -26,11 +26,12 @@ module Mysh
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
#The show command action object.
|
29
|
+
# The show command action object.
|
30
30
|
COMMANDS.add_action(Action.new('show <item>', desc, &action))
|
31
31
|
SHOW_COMMAND = Action.new('@<item>', desc, &action)
|
32
32
|
COMMANDS.add_action(SHOW_COMMAND)
|
33
33
|
end
|
34
34
|
|
35
|
-
#Load up the
|
36
|
-
|
35
|
+
# Load up the various show actions!
|
36
|
+
path = MYSH_LIB + "mysh/show/*.rb"
|
37
|
+
Dir[path].each {|file| require file }
|
@@ -1,12 +1,12 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal help sub commands.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
|
6
|
+
# The mysh internal help sub commands.
|
7
7
|
class HelpSubCommand < Action
|
8
8
|
|
9
|
-
#Setup a help command.
|
9
|
+
# Setup a help command.
|
10
10
|
def initialize(name, description, file_name)
|
11
11
|
super(name, description)
|
12
12
|
@file_name = file_name
|
@@ -14,12 +14,13 @@ module Mysh
|
|
14
14
|
|
15
15
|
#Execute a help command.
|
16
16
|
def process_command(_args)
|
17
|
-
|
17
|
+
path = MYSH_LIB + "mysh/help/" + @file_name
|
18
|
+
mysh "load #{path.to_host_spec}"
|
18
19
|
end
|
19
20
|
|
20
21
|
end
|
21
22
|
|
22
|
-
#Add help topics here. Don't sweat the order; they get sorted by name.
|
23
|
+
# Add help topics here. Don't sweat the order; they get sorted by name.
|
23
24
|
# Name Description Help File
|
24
25
|
help = [['', 'General help on mysh.', 'help.txt' ],
|
25
26
|
['set', 'Help on mysh variables.', 'vars.txt' ],
|
@@ -34,13 +35,14 @@ module Mysh
|
|
34
35
|
['usage', 'Help on mysh usage.', 'usage.txt' ],
|
35
36
|
['=', 'Help on ruby expressions.', 'expr.txt' ],
|
36
37
|
['quick', 'Help on quick commands.', 'quick.txt' ],
|
37
|
-
['gls', 'Help on gls
|
38
|
-
['mls', 'Help on mls
|
38
|
+
['gls', 'Help on the gls command.', 'gls.txt' ],
|
39
|
+
['mls', 'Help on the mls command.', 'mls.txt' ],
|
39
40
|
['!', 'Help on the history command.', 'history.txt'],
|
40
41
|
['history', 'Help on the history command.', 'history.txt'],
|
41
42
|
['kbd', 'Help on mysh keyboard mapping.', 'kbd.txt' ],
|
42
43
|
['{{', 'Help on mysh handlebars.', 'hbar.txt' ],
|
43
44
|
['init', 'Help on mysh initialization.', 'init.txt' ],
|
45
|
+
['type', 'Help on the type command.', 'type.txt' ],
|
44
46
|
['types', 'Help on mysh file types.', 'types.txt' ],
|
45
47
|
['help', 'This help on the help command.', 'h_o_h.txt' ],
|
46
48
|
['?', 'This help on the help command.', 'h_o_h.txt' ]
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
# The mysh type command.
|
4
|
+
module Mysh
|
5
|
+
|
6
|
+
# Add the type command to the library.
|
7
|
+
desc = 'Display one or more text files with optional support for ' +
|
8
|
+
'embedded handlebars and shell variables. See ?type for more.'
|
9
|
+
|
10
|
+
action = lambda do |input|
|
11
|
+
count = 0
|
12
|
+
cooked = MNV[:type] !~ /\A(raw|false|no|off)\z/i
|
13
|
+
args = input.args
|
14
|
+
|
15
|
+
args.each do |file_name|
|
16
|
+
puts file_name if args.length > 1
|
17
|
+
|
18
|
+
case file_name
|
19
|
+
when "-c"
|
20
|
+
cooked = false
|
21
|
+
when "+c"
|
22
|
+
cooked = true
|
23
|
+
else
|
24
|
+
if cooked
|
25
|
+
show_handlebar_file(file_name, binding)
|
26
|
+
else
|
27
|
+
puts IO.read(file_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
count += 1
|
32
|
+
end
|
33
|
+
|
34
|
+
fail "A text file must be specified." if count == 0
|
35
|
+
end
|
36
|
+
|
37
|
+
COMMANDS.add_action(Action.new('type <files>', desc, &action))
|
38
|
+
end
|
@@ -1,24 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh internal variables commands.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
|
6
|
+
# The mysh internal variable commands.
|
7
7
|
class VarsCommand < Action
|
8
8
|
|
9
|
-
#The mysh variable parsing regex.
|
9
|
+
# The mysh variable parsing regex.
|
10
10
|
VAR_EXP = %r{(?<name> [a-z][a-z0-9_]*){0}
|
11
11
|
(?<equals> =){0}
|
12
12
|
(?<value> \S.*){0}
|
13
13
|
\$ (\g<name> \s* (\g<equals> \s* \g<value>?)?)?}x
|
14
14
|
|
15
|
-
#Setup an internal action.
|
15
|
+
# Setup an internal action.
|
16
16
|
def initialize(name, description)
|
17
17
|
@var_name = @equals = @value = nil
|
18
18
|
super(name, description)
|
19
19
|
end
|
20
20
|
|
21
|
-
#Execute a command against the internal mysh variables.
|
21
|
+
# Execute a command against the internal mysh variables.
|
22
22
|
def process_command(input)
|
23
23
|
if (match = VAR_EXP.match(input.raw_body))
|
24
24
|
@var_name, @equals, @value = match[:name], match[:equals], match[:value]
|
@@ -30,7 +30,7 @@ module Mysh
|
|
30
30
|
:internal
|
31
31
|
end
|
32
32
|
|
33
|
-
#Do the actual work here.
|
33
|
+
# Do the actual work here.
|
34
34
|
def do_command
|
35
35
|
sym = @var_name.to_sym if @var_name
|
36
36
|
|
@@ -45,7 +45,7 @@ module Mysh
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
#Display all variables neatly.
|
48
|
+
# Display all variables neatly.
|
49
49
|
def show_all_values
|
50
50
|
puts (MNV.keys - ['$'.to_sym])
|
51
51
|
.sort
|
@@ -55,7 +55,7 @@ module Mysh
|
|
55
55
|
|
56
56
|
end
|
57
57
|
|
58
|
-
#The
|
58
|
+
# The set command action object.
|
59
59
|
desc = 'Set/query mysh variables. See ?set for more.'
|
60
60
|
COMMANDS.add_action(VarsCommand.new('set <$name>=value', desc))
|
61
61
|
end
|
File without changes
|
data/lib/mysh/process.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
3
|
+
# The mysh command processors.
|
4
4
|
module Mysh
|
5
5
|
|
6
|
-
#Process from the console.
|
6
|
+
# Process from the console.
|
7
7
|
def self.process_console
|
8
8
|
process_source(Console.new)
|
9
9
|
end
|
10
10
|
|
11
|
-
#Process from a string.
|
11
|
+
# Process from a string.
|
12
12
|
def self.process_string(str)
|
13
13
|
process_source(StringSource.new(str))
|
14
14
|
end
|
15
15
|
|
16
|
-
#Process from a file.
|
16
|
+
# Process from a file.
|
17
17
|
def self.process_file(name)
|
18
18
|
process_source(StringSource.new(IO.read(name)))
|
19
19
|
end
|
20
20
|
|
21
|
-
#Process commands from a source.
|
21
|
+
# Process commands from a source.
|
22
22
|
def self.process_source(source)
|
23
23
|
until source.eoi? do
|
24
24
|
execute_a_command(source)
|
@@ -26,7 +26,7 @@ module Mysh
|
|
26
26
|
rescue MyshExit
|
27
27
|
end
|
28
28
|
|
29
|
-
#Execute a single line of input and handle exceptions.
|
29
|
+
# Execute a single line of input and handle exceptions.
|
30
30
|
def self.execute_a_command(source)
|
31
31
|
try_execute_command(get_command(source))
|
32
32
|
|
@@ -38,7 +38,7 @@ module Mysh
|
|
38
38
|
puts err.backtrace if MNV[:debug].extract_boolean || defined?(MiniTest)
|
39
39
|
end
|
40
40
|
|
41
|
-
#Try to execute a single line of input. Does not handle exceptions.
|
41
|
+
# Try to execute a single line of input. Does not handle exceptions.
|
42
42
|
def self.try_execute_command(str)
|
43
43
|
input = InputWrapper.new(str)
|
44
44
|
|