commandant 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +1 -1
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/commandant.rb +6 -3
- data/spec/commandant_spec.rb +1 -1
- metadata +2 -2
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/commandant.rb
CHANGED
@@ -55,7 +55,7 @@ module Commandant
|
|
55
55
|
# end
|
56
56
|
#
|
57
57
|
# Commandant.run "argprint foo bizz bazz"
|
58
|
-
def command(name, description=
|
58
|
+
def command(name, description=nil, &command)
|
59
59
|
Command.new(name, description, &command)
|
60
60
|
end
|
61
61
|
module_function :command
|
@@ -68,8 +68,11 @@ module Commandant
|
|
68
68
|
# @raise [UnknownCommand] command is unknown and no :main command is available
|
69
69
|
def run(cmdline=ARGV)
|
70
70
|
name, *args = cmdline
|
71
|
-
name
|
72
|
-
|
71
|
+
name = name.to_sym if name
|
72
|
+
|
73
|
+
name, *args = :main, name, *args unless COMMANDS[name]
|
74
|
+
|
75
|
+
Commandant.call name, args.compact
|
73
76
|
end
|
74
77
|
module_function :run
|
75
78
|
|
data/spec/commandant_spec.rb
CHANGED
@@ -63,7 +63,7 @@ describe Commandant do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "defaults to the :main command, if available" do
|
66
|
-
Commandant.run(%w{ some args }).should == 'main called with [
|
66
|
+
Commandant.run(%w{ some args }).should == 'main called with [:some, "args"]'
|
67
67
|
end
|
68
68
|
|
69
69
|
it "runs the main command if no arguments are passed" do
|