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 CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Rein Henrichs
1
+ Copyright (c) 2010 Rein Henrichs
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.rdoc CHANGED
@@ -24,7 +24,7 @@ what you want and none of what you don't. If you don't like it, don't use it.
24
24
  === Provides:
25
25
 
26
26
  * <tt>basic hello</tt>
27
- * <tt>basic argprint foo bar bazz
27
+ * <tt>basic argprint foo bar bazz</tt>
28
28
 
29
29
  == Note on Patches/Pull Requests
30
30
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
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="", &command)
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, args = :main, [name, *args] if name.nil? || COMMANDS[name.to_sym].nil? && COMMANDS[:main]
72
- Commandant.call name.to_sym, args.compact
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
 
@@ -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 ["some", "args"]'
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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rein Henrichs