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 +7 -0
- data/Manifest +1 -1
- data/commander.gemspec +3 -3
- data/lib/commander.rb +0 -1
- data/lib/commander/runner.rb +6 -5
- data/lib/commander/version.rb +1 -1
- data/spec/runner_spec.rb +15 -7
- metadata +3 -3
- data/Todo.rdoc +0 -33
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
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.
|
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-
|
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/
|
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
data/lib/commander/runner.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
55
|
-
rescue
|
56
|
-
|
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
|
-
$
|
303
|
+
$terminal.say *args
|
303
304
|
end
|
304
305
|
|
305
306
|
end
|
data/lib/commander/version.rb
CHANGED
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
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
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
|