shell-utils 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shellutils/argument_parser.rb +24 -0
- metadata +4 -3
@@ -0,0 +1,24 @@
|
|
1
|
+
class ArgumentParser
|
2
|
+
|
3
|
+
def initialize commands
|
4
|
+
@commands = commands
|
5
|
+
end
|
6
|
+
|
7
|
+
def parse params
|
8
|
+
params[0] = params[0] ? params[0].downcase : 'help'
|
9
|
+
command_name = params[0]
|
10
|
+
command_executed = false
|
11
|
+
@commands.each do |command|
|
12
|
+
if command.accepts_shell_command?(command_name)
|
13
|
+
command.execute_from_shell params
|
14
|
+
command_executed = true
|
15
|
+
end
|
16
|
+
end
|
17
|
+
if not command_executed and command_name == "spec"
|
18
|
+
# 'spec" is for testing purpose only: do nothing special
|
19
|
+
elsif not command_executed
|
20
|
+
raise ShellArgumentException.new command_name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- CodersDojo-Team
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-09-
|
17
|
+
date: 2011-09-29 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -40,6 +40,7 @@ extensions: []
|
|
40
40
|
extra_rdoc_files: []
|
41
41
|
|
42
42
|
files:
|
43
|
+
- lib/shellutils/argument_parser.rb
|
43
44
|
- lib/shellutils/date_time_formatter.rb
|
44
45
|
- lib/shellutils/filename.rb
|
45
46
|
- lib/shellutils/progress.rb
|