visionmedia-commander 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,9 @@
1
1
 
2
+ === 3.0.1 / 2009-03-12
3
+
4
+ * Fixed bug in #command_name_from_args preventing the left-most match for a command name to be used
5
+ * Fixed bug in Command#example preventing the formatter from outputting them correctly
6
+
2
7
  === 3.0.0 / 2009-03-12
3
8
 
4
9
  * Added sub command help support when using the --help switch
data/README.rdoc CHANGED
@@ -32,22 +32,30 @@ as well as an object, specifying a method to call, so view the RDoc for more inf
32
32
  program :description, 'Stupid command that prints foo or bar.'
33
33
 
34
34
  command :foo do |c|
35
- c.syntax = "foobar foo"
36
- c.description = "Displays foo"
35
+ c.syntax = 'foobar foo'
36
+ c.description = 'Displays foo'
37
37
  c.when_called do |args, options|
38
- say "foo"
38
+ say 'foo'
39
39
  end
40
40
  end
41
41
 
42
42
  command :bar do |c|
43
- c.syntax = "foobar [options] bar"
44
- c.description = "Display bar with optional prefix"
45
- c.option "--prefix STRING"
43
+ c.syntax = 'foobar bar [options]'
44
+ c.description = 'Display bar with optional prefix and suffix'
45
+ c.option '--prefix STRING', String, 'Adds a prefix to bar'
46
+ c.option '--suffix STRING', String, 'Adds a suffix to bar'
46
47
  c.when_called do |args, options|
47
- say "#{options.prefix} bar"
48
+ options.default :prefix => '(', :suffix => ')'
49
+ say "#{options.prefix}bar#{options.suffix}"
48
50
  end
49
51
  end
50
52
 
53
+ $ foobar bar
54
+ # => (bar)
55
+
56
+ $ foobar bar --suffix '{' --prefix '}'
57
+ # => {bar}
58
+
51
59
  == HighLine
52
60
 
53
61
  As mentioned above the highline gem is imported into 'global scope', below
data/Todo.rdoc CHANGED
@@ -1,11 +1,14 @@
1
1
 
2
2
  == Major
3
3
 
4
+ * Fix help command ...
5
+ * Rough out some formatter specs using include?
4
6
  * 1.9.x compatability
5
7
  * Publish RDoc on mini page / screencasts
6
8
 
7
9
  == Minor
8
10
 
11
+ * Add optional default command when none is present
9
12
  * Fix multi-word command template creation via `commander init`
10
13
  * Consider global #color method again
11
14
  * Change; use stack technique for progress bar instead to clean things up
data/commander.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.0.0"
5
+ s.version = "3.0.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
@@ -41,7 +41,7 @@ module Commander
41
41
  #
42
42
 
43
43
  def example description, command
44
- @examples.push description, command
44
+ @examples << [description, command]
45
45
  end
46
46
 
47
47
  ##
@@ -207,7 +207,7 @@ module Commander
207
207
 
208
208
  def option_proc switches
209
209
  Proc.new do |value|
210
- @proxy_options.push [switch_to_sym(switches.last), value]
210
+ @proxy_options << [switch_to_sym(switches.last), value]
211
211
  end
212
212
  end
213
213
 
@@ -132,10 +132,19 @@ module Commander
132
132
 
133
133
  ##
134
134
  # Attemps to locate a command name from within the arguments.
135
- # Supports multi-word commands, using the largest possible match.
135
+ # Supports multi-word commands, using the largest left-most possible match.
136
136
 
137
137
  def command_name_from_args
138
- @__command_name_from_args ||= valid_command_names_from(*@args.dup).last
138
+ @__command_name_from_args ||= begin
139
+ names = valid_command_names_from *@args.dup
140
+ if names.length > 1
141
+ names.first.length == names.last.length ?
142
+ names.first :
143
+ names.last
144
+ else
145
+ names.first
146
+ end
147
+ end
139
148
  end
140
149
 
141
150
  ##
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.0.0'
3
+ VERSION = '3.0.1'
4
4
  end
data/spec/runner_spec.rb CHANGED
@@ -101,6 +101,11 @@ describe Commander do
101
101
  command('foo bar foo') {}
102
102
  command_runner.command_name_from_args.should == 'foo bar foo'
103
103
  end
104
+
105
+ it "should use the left-most command name when multiple are present" do
106
+ new_command_runner 'help', 'test'
107
+ command_runner.command_name_from_args.should == 'help'
108
+ end
104
109
  end
105
110
 
106
111
  describe "#active_command" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-commander
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk