visionmedia-commander 3.1.7 → 3.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/History.rdoc CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ === 3.1.8 / 2009-03-25
3
+
4
+ * Utilizing abort and $stderr instead of using #say [#16]
5
+ * Fixed INT trapping issue (purely cosmetic) [#14]
6
+ * Removed todo, use lighthouse now for commander at:
7
+ http://visionmedia.lighthouseapp.com/projects/27643-commander/overview
8
+
2
9
  === 3.1.7 / 2009-03-24
3
10
 
4
11
  * Added global --trace option
data/Manifest CHANGED
@@ -32,5 +32,5 @@ tasks/gemspec.rake
32
32
  tasks/spec.rake
33
33
  test/foo
34
34
  test/pbar
35
+ test/re
35
36
  test/ui
36
- Todo.rdoc
data/commander.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{commander}
5
- s.version = "3.1.7"
5
+ s.version = "3.1.8"
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"]
9
- s.date = %q{2009-03-24}
9
+ s.date = %q{2009-03-25}
10
10
  s.default_executable = %q{commander}
11
11
  s.description = %q{The complete solution for Ruby command-line executables}
12
12
  s.email = %q{tj@vision-media.ca}
13
13
  s.executables = ["commander"]
14
14
  s.extra_rdoc_files = ["bin/commander", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/core_ext/string.rb", "lib/commander/core_ext.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "lib/commander.rb", "README.rdoc", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake"]
15
- s.files = ["bin/commander", "commander.gemspec", "History.rdoc", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/core_ext/string.rb", "lib/commander/core_ext.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "lib/commander.rb", "Manifest", "Rakefile", "README.rdoc", "spec/command_spec.rb", "spec/core_ext/array_spec.rb", "spec/core_ext/object_spec.rb", "spec/core_ext/string_spec.rb", "spec/help_formatters/base_spec.rb", "spec/help_formatters/terminal_spec.rb", "spec/runner_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "test/foo", "test/pbar", "test/ui", "Todo.rdoc"]
15
+ s.files = ["bin/commander", "commander.gemspec", "History.rdoc", "lib/commander/blank.rb", "lib/commander/command.rb", "lib/commander/core_ext/array.rb", "lib/commander/core_ext/object.rb", "lib/commander/core_ext/string.rb", "lib/commander/core_ext.rb", "lib/commander/help_formatters/base.rb", "lib/commander/help_formatters/terminal/command_help.erb", "lib/commander/help_formatters/terminal/help.erb", "lib/commander/help_formatters/terminal.rb", "lib/commander/help_formatters.rb", "lib/commander/runner.rb", "lib/commander/user_interaction.rb", "lib/commander/version.rb", "lib/commander.rb", "Manifest", "Rakefile", "README.rdoc", "spec/command_spec.rb", "spec/core_ext/array_spec.rb", "spec/core_ext/object_spec.rb", "spec/core_ext/string_spec.rb", "spec/help_formatters/base_spec.rb", "spec/help_formatters/terminal_spec.rb", "spec/runner_spec.rb", "spec/spec_helper.rb", "tasks/docs.rake", "tasks/gemspec.rake", "tasks/spec.rake", "test/foo", "test/pbar", "test/re", "test/ui"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://visionmedia.github.com/commander}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Commander", "--main", "README.rdoc"]
data/lib/commander.rb CHANGED
@@ -32,5 +32,4 @@ require 'commander/help_formatters'
32
32
 
33
33
  $command_runner = Commander::Runner.new
34
34
  $terminal.wrap_at = HighLine::SystemExtensions.terminal_size.first - 10 rescue 80
35
- trap('INT') { abort program(:int_message) }
36
35
  at_exit { run! }
@@ -37,6 +37,7 @@ module Commander
37
37
  def run!
38
38
  trace = false
39
39
  require_program :name, :version, :description
40
+ trap('INT') { abort program(:int_message) }
40
41
  global_option('--help', 'Display help documentation') { command(:help).run *@args[1..-1]; return }
41
42
  global_option('--version', 'Display version information') { say version; return }
42
43
  global_option('--trace', 'Display backtrace when an error occurs') { trace = true }
@@ -46,14 +47,14 @@ module Commander
46
47
  begin
47
48
  call_active_command
48
49
  rescue InvalidCommandError
49
- say 'invalid command. Use --help for more information'
50
+ abort 'invalid command. Use --help for more information'
50
51
  rescue \
51
52
  OptionParser::InvalidOption,
52
53
  OptionParser::InvalidArgument,
53
54
  OptionParser::MissingArgument => e
54
- say e
55
- rescue Exception => e
56
- say "error: #{e}. Use --trace to view backtrace"
55
+ abort e
56
+ rescue => e
57
+ abort "error: #{e}. Use --trace to view backtrace"
57
58
  end
58
59
  else
59
60
  call_active_command
@@ -299,7 +300,7 @@ module Commander
299
300
  private
300
301
 
301
302
  def say *args #:nodoc:
302
- $termina.say *args
303
+ $terminal.say *args
303
304
  end
304
305
 
305
306
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module Commander
3
- VERSION = '3.1.7'
3
+ VERSION = '3.1.8'
4
4
  end
data/spec/runner_spec.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  describe Commander do
3
3
 
4
4
  before :each do
5
+ $stderr = StringIO.new
5
6
  mock_terminal
6
7
  create_test_command
7
8
  end
@@ -64,10 +65,11 @@ describe Commander do
64
65
 
65
66
  describe "--trace" do
66
67
  it "should display pretty errors by default" do
67
- new_command_runner 'foo' do
68
- command(:foo) { |c| c.when_called { raise 'cookies!' } }
69
- end.run!
70
- @output.string.should == "error: cookies!. Use --trace to view backtrace\n"
68
+ lambda {
69
+ new_command_runner 'foo' do
70
+ command(:foo) { |c| c.when_called { raise 'cookies!' } }
71
+ end.run!
72
+ }.should raise_error(SystemExit, /error: cookies!. Use --trace/)
71
73
  end
72
74
 
73
75
  it "should display callstack when using this switch" do
@@ -93,19 +95,25 @@ describe Commander do
93
95
 
94
96
  describe "with invalid options" do
95
97
  it "should output an invalid option message" do
96
- run('test', '--invalid-option').should == "invalid option: --invalid-option\n"
98
+ lambda {
99
+ run('test', '--invalid-option')
100
+ }.should raise_error(SystemExit, /invalid option: --invalid-option/)
97
101
  end
98
102
  end
99
103
 
100
104
  describe "with invalid sub-command passed" do
101
105
  it "should output an invalid command message" do
102
- run('foo').should == "invalid command. Use --help for more information\n"
106
+ lambda {
107
+ run('foo')
108
+ }.should raise_error(SystemExit, /invalid command. Use --help for more information/)
103
109
  end
104
110
  end
105
111
 
106
112
  describe "with invalid sub-command passed to help" do
107
113
  it "should output an invalid command message" do
108
- run('help', 'does_not_exist').should == "invalid command. Use --help for more information\n"
114
+ lambda {
115
+ run('help', 'does_not_exist')
116
+ }.should raise_error(SystemExit, /invalid command. Use --help for more information/)
109
117
  end
110
118
  end
111
119
 
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.1.7
4
+ version: 3.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-24 00:00:00 -07:00
12
+ date: 2009-03-25 00:00:00 -07:00
13
13
  default_executable: commander
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -84,8 +84,8 @@ files:
84
84
  - tasks/spec.rake
85
85
  - test/foo
86
86
  - test/pbar
87
+ - test/re
87
88
  - test/ui
88
- - Todo.rdoc
89
89
  has_rdoc: true
90
90
  homepage: http://visionmedia.github.com/commander
91
91
  post_install_message:
data/Todo.rdoc DELETED
@@ -1,33 +0,0 @@
1
-
2
- == Major
3
-
4
- * Finish global --trace
5
- * 1.9.x compatability
6
- * Publish RDoc on mini page / screencasts
7
-
8
- == Minor
9
-
10
- * Better custom shell support ... Highline stuff is not very nice
11
- * Prevent global options from overriding sub-command level options
12
- * Add arbitrary help blocks to sub-commands as well
13
- * Spec for changing out formatters (mock formatter)
14
- * Add optional default command when none is present
15
- * Fix multi-word command template creation via `commander init`
16
- * Consider global #color method again
17
- * Change; use stack technique for progress bar instead to clean things up
18
- * Add; dynamically generate padding erb templates, command lists, multi-line text bodies etc
19
- * Add optional command to be executed when none is specified
20
- * Add global options... change runner implementations as well as displaying in terminal formatter, OpenStruct inherit these options?
21
- * Add highline paging ... clean it up because its ugly
22
- * Add option copying / merging capabilities
23
- * Change; require that users explicitly require 'commander/import' (which in turn will highlight/import as well)
24
- * Release to RubyForge as well
25
- * Change; consider reversing |options, args| so args make use of ruby block param defaults with 1.9
26
- or simply just to expand arg params like so |options, source_dir, dest_dir| ...
27
-
28
- == Brainstorming
29
-
30
- * Add global trapping of INT to end process with less ugly output
31
- * Add global --options switch for loading options from a filepath
32
- * Add argument parser / defaults
33
- * Add regexp matching for command names