visionmedia-commander 1.2.2 → 2.4.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.
@@ -1,42 +1,223 @@
1
1
 
2
2
  describe Commander do
3
-
3
+
4
4
  before :each do
5
- init_commander :version => '1.3.2', :name => 'My Program'
6
- command :test_command do |c|
7
- c.syntax = 'test_command [options]'
8
- c.description = 'Just a test command.'
9
- c.option '-h', '--help', 'View help information.'
10
- c.option '--version', 'View program version.'
11
- c.option '-v', '--verbose', 'Verbose output.'
12
- c.example 'View help', 'test_command --help'
13
- c.example 'View version', 'test_command --version'
14
- end
15
- @manager = Commander::Manager.instance
5
+ @input = StringIO.new
6
+ @output = StringIO.new
7
+ $terminal = HighLine.new @input, @output
8
+ create_test_command
16
9
  end
17
10
 
18
- it "should add commands" do
19
- @manager.length.should == 1
11
+ it "should allow access to all commands using #commands" do
12
+ commands.length.should eql(2) # our test command as well as help default
20
13
  end
21
14
 
22
- it "should fetch commands with the #get_command method" do
23
- get_command(:test_command).syntax.should == 'test_command [options]'
15
+ it "should set program information using #program" do
16
+ program :name, "test"
17
+ program :version, "1.2.3"
18
+ program :description, "just a test."
19
+ program(:name).should eql("test")
20
+ program(:version).should eql("1.2.3")
21
+ program(:description).should eql("just a test.")
24
22
  end
25
23
 
26
- it "should test existance of a command using #command_exists?" do
27
- command_exists?(:test_command).should == true
28
- command_exists?(:test).should == false
24
+ it "should allow arbitrary blocks of global help documentation" do
25
+ program :help, 'Copyright', 'TJ Holowaychuk'
26
+ program(:help)['Copyright'].should eql('TJ Holowaychuk')
29
27
  end
30
28
 
31
- it "should inialize and set the version" do
32
- info(:version).should == '1.3.2'
33
- info(:major).should == 1
34
- info(:minor).should == 3
35
- info(:tiny).should == 2
29
+ it "should raise an error when crutial program info is not set" do
30
+ new_command_runner '--help'
31
+ program :name, ''
32
+ lambda { run! }.should raise_error(Commander::Runner::CommandError)
33
+ end
34
+
35
+ it "should output program version using --version switch" do
36
+ new_command_runner '--version'
37
+ program :help_formatter, Commander::HelpFormatter::Base
38
+ command_runner.run!
39
+ @output.string.should eql("test 1.2.3\n")
40
+ end
41
+
42
+ it "should get command instances using #get_command" do
43
+ get_command(:test).name.should eql('test')
36
44
  end
37
45
 
38
- it "should set program name" do
39
- info(:name).should == 'My Program'
46
+ it "should assign options" do
47
+ get_command(:test).options.length.should eql(2)
40
48
  end
41
- end
49
+
50
+ it "should invoke #when_called with arguments properly" do
51
+ get_command(:test).call([1, 2]).should eql("test 12")
52
+ end
53
+
54
+ it "should output invalid option message when invalid options passed to command" do
55
+ new_command_runner 'test', '--invalid-option'
56
+ command_runner.run!
57
+ @output.string.should eql("invalid option: --invalid-option\n")
58
+ end
59
+
60
+ it "should output invalid command message when help sub-command does not exist" do
61
+ new_command_runner 'help', 'does_not_exist'
62
+ command_runner.run!
63
+ @output.string.should eql("invalid command. Use --help for more information\n")
64
+ end
42
65
 
66
+ it "should locate command within arbitrary arguments passed" do
67
+ new_command_runner '--help', '--arbitrary', 'test'
68
+ command_runner.command_name_from_args.should eql('test')
69
+ end
70
+
71
+ it "should resolve active command from global options passed" do
72
+ new_command_runner '--help', 'test'
73
+ command_runner.active_command.should be_instance_of(Commander::Command)
74
+ end
75
+
76
+ it "should distinguish between switches and descriptions passed to #option" do
77
+ get_command(:test).options[0][:description].should eql("trace description")
78
+ get_command(:test).options[0][:switches].should eql(["-t", "--trace"])
79
+ get_command(:test).options[1][:description].should eql("verbose description")
80
+ get_command(:test).options[1][:switches].should eql(["--verbose"])
81
+ get_command(:test).option "--test"
82
+ get_command(:test).options[2][:description].should be_nil
83
+ get_command(:test).options[2][:switches].should eql(["--test"])
84
+ end
85
+
86
+ it "should generate a symbol from switches" do
87
+ get_command(:test).sym_from_switch("--trace").should eql(:trace)
88
+ get_command(:test).sym_from_switch("--foo-bar").should eql(:foo_bar)
89
+ get_command(:test).sym_from_switch("--[no]-feature").should eql(:feature)
90
+ get_command(:test).sym_from_switch("--[no]-feature ARG").should eql(:feature)
91
+ get_command(:test).sym_from_switch("--file [ARG]").should eql(:file)
92
+ get_command(:test).sym_from_switch("--colors colors").should eql(:colors)
93
+ end
94
+
95
+ it "should resolve active command from invalid options passed" do
96
+ new_command_runner '--help', 'test', '--arbitrary'
97
+ command_runner.active_command.should be_instance_of(Commander::Command)
98
+ end
99
+
100
+ it "should raise invalid command error when the command is not found in the arguments passed"do
101
+ new_command_runner '--help'
102
+ lambda { command_runner.active_command }.should raise_error(Commander::Runner::InvalidCommandError)
103
+ end
104
+
105
+ it "should add options to previously created commands" do
106
+ get_command(:test).option("--recursive") {}
107
+ get_command(:test).options.length.should eql(3)
108
+ end
109
+
110
+ it "should call command option procs" do
111
+ recursive = false
112
+ get_command(:test).option("--recursive") { recursive = true }
113
+ get_command(:test).run ['--recursive']
114
+ recursive.should be_true
115
+ end
116
+
117
+ it "should call the #when_called proc when #run" do
118
+ result = nil
119
+ get_command(:test).when_called { |args, options| result = args.join(' ') }
120
+ get_command(:test).run ['--trace', 'just', 'some', 'args']
121
+ result.should eql("just some args")
122
+ end
123
+
124
+ it "should handle boolean options" do
125
+ opts = nil
126
+ get_command(:test).when_called { |args, options| opts = options }
127
+ get_command(:test).run ['--trace', 'foo', 'bar']
128
+ opts.trace.should be_true
129
+ end
130
+
131
+ it "should handle toggle options" do
132
+ options = nil
133
+ get_command(:test).when_called { |args, opts| options = opts }
134
+ get_command(:test).option "--[no-]toggle"
135
+ get_command(:test).run ['--no-toggle']
136
+ options.toggle.should be_false
137
+ end
138
+
139
+ it "should handle manditory arg options" do
140
+ options = nil
141
+ get_command(:test).when_called { |args, opts| options = opts }
142
+ get_command(:test).option "--manditory ARG"
143
+ get_command(:test).run ['--manditory', "foo"]
144
+ options.manditory.should eql("foo")
145
+ lambda { get_command(:test).run ['--manditory'] }.should raise_error(OptionParser::MissingArgument)
146
+ end
147
+
148
+ it "should handle optional arg options" do
149
+ options = nil
150
+ get_command(:test).when_called { |args, opts| options = opts }
151
+ get_command(:test).option "--optional [ARG]"
152
+ get_command(:test).run ['--optional', "foo"]
153
+ options.optional.should eql("foo")
154
+ get_command(:test).run ['--optional']
155
+ options.optiona.should be_nil
156
+ end
157
+
158
+ it "should handle list options" do
159
+ options = nil
160
+ get_command(:test).when_called { |args, opts| options = opts }
161
+ get_command(:test).option "--list words", Array
162
+ get_command(:test).run ['--list', "im,a,list"]
163
+ options.list.should eql(["im", "a", "list"])
164
+ end
165
+
166
+ it "should initialize and call object when a class is passed to #when_called" do
167
+ $_when_called_value = nil
168
+ class HandleWhenCalled1
169
+ def initialize(args, options) $_when_called_value = args.join('-') end
170
+ end
171
+ get_command(:test).when_called HandleWhenCalled1
172
+ get_command(:test).call(["hello", "world"])
173
+ $_when_called_value.should eql("hello-world")
174
+ end
175
+
176
+ it "should initialize and call object when a class is passed to #when_called with an arbitrary method" do
177
+ class HandleWhenCalled2
178
+ def arbitrary_method(args, options) args.join('-') end
179
+ end
180
+ get_command(:test).when_called HandleWhenCalled2, :arbitrary_method
181
+ get_command(:test).call(["hello", "world"]).should eql("hello-world")
182
+ end
183
+
184
+ it "should call object when passed to #when_called " do
185
+ class HandleWhenCalled3
186
+ def arbitrary_method(args, options) args.join('-') end
187
+ end
188
+ get_command(:test).when_called HandleWhenCalled3.new, :arbitrary_method
189
+ get_command(:test).call(["hello", "world"]).should eql("hello-world")
190
+ end
191
+
192
+ it "should populate options when passed before command name" do
193
+ options = nil
194
+ new_command_runner '--foo', 'test', 'some', 'args'
195
+ get_command(:test).option "--foo"
196
+ get_command(:test).when_called { |args, opts| options = opts }
197
+ command_runner.run!
198
+ options.foo.should be_true
199
+ end
200
+
201
+ it "should populate options when passed after command name" do
202
+ options = nil
203
+ new_command_runner 'test', '--foo', 'some', 'args'
204
+ get_command(:test).option "--foo"
205
+ get_command(:test).when_called { |args, opts| options = opts }
206
+ command_runner.run!
207
+ options.foo.should be_true
208
+ end
209
+
210
+ it "should allow multi-word strings as command names to be called correctly" do
211
+ arguments = nil
212
+ options = nil
213
+ new_command_runner 'foo', 'bar', 'i', 'like', '--i-like', 'cookies', 'bar'
214
+ command 'foo bar' do |c|
215
+ c.option '--i-like WHAT'
216
+ c.when_called { |args, opts| arguments, options = args, opts }
217
+ end
218
+ command_runner.run!
219
+ arguments.should eql(['i', 'like', 'bar'])
220
+ options.i_like.should eql('cookies')
221
+ end
222
+
223
+ end
@@ -0,0 +1,31 @@
1
+
2
+ describe Commander::HelpFormatter do
3
+
4
+ before :each do
5
+ @input = StringIO.new
6
+ @output = StringIO.new
7
+ $terminal = HighLine.new @input, @output
8
+ end
9
+
10
+ it "should display global help using --help switch" do
11
+ new_command_runner '--help'
12
+ program :help_formatter, Commander::HelpFormatter::Base
13
+ command_runner.run!
14
+ @output.string.should eql("Implement global help here\n")
15
+ end
16
+
17
+ it "should display global help using help command" do
18
+ new_command_runner 'help'
19
+ program :help_formatter, Commander::HelpFormatter::Base
20
+ command_runner.run!
21
+ @output.string.should eql("Implement global help here\n")
22
+ end
23
+
24
+ it "should display command help" do
25
+ new_command_runner 'help', 'test'
26
+ program :help_formatter, Commander::HelpFormatter::Base
27
+ command_runner.run!
28
+ @output.string.should eql("Implement help for test here\n")
29
+ end
30
+
31
+ end
@@ -0,0 +1,25 @@
1
+
2
+ require 'commander'
3
+ require 'stringio'
4
+
5
+ def create_test_command
6
+ command :test do |c|
7
+ c.syntax = "test [options] <file>"
8
+ c.description = "test description"
9
+ c.example "description", "command"
10
+ c.example "description 2", "command 2"
11
+ c.option "-t", "--trace", "trace description"
12
+ c.option "--verbose", "verbose description"
13
+ c.when_called do |args, options|
14
+ "test %s" % args.join
15
+ end
16
+ end
17
+ end
18
+
19
+ def new_command_runner *args
20
+ $command_runner = Commander::Runner.new args
21
+ program :name, "test"
22
+ program :version, "1.2.3"
23
+ program :description, "something"
24
+ create_test_command
25
+ end
data/tasks/docs.rake ADDED
@@ -0,0 +1,13 @@
1
+
2
+ namespace :docs do
3
+
4
+ desc 'Remove rdoc products'
5
+ task :remove => [:clobber_docs]
6
+
7
+ desc 'Build docs, and open in browser for viewing (specify BROWSER)'
8
+ task :open => [:docs] do
9
+ browser = ENV["BROWSER"] || "safari"
10
+ sh "open -a #{browser} doc/index.html"
11
+ end
12
+
13
+ end
@@ -0,0 +1,3 @@
1
+
2
+ desc 'Build gemspec file'
3
+ task :gemspec => [:build_gemspec]
data/tasks/spec.rake ADDED
@@ -0,0 +1,25 @@
1
+
2
+ require 'spec/rake/spectask'
3
+
4
+ desc "Run all specifications"
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ t.libs << "lib"
7
+ t.spec_opts = ["--color", "--require", "spec/spec_helper.rb"]
8
+ end
9
+
10
+ namespace :spec do
11
+
12
+ desc "Run all specifications verbosely"
13
+ Spec::Rake::SpecTask.new(:verbose) do |t|
14
+ t.libs << "lib"
15
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
16
+ end
17
+
18
+ desc "Run specific specification verbosely (specify SPEC)"
19
+ Spec::Rake::SpecTask.new(:select) do |t|
20
+ t.libs << "lib"
21
+ t.spec_files = [ENV["SPEC"]]
22
+ t.spec_opts = ["--color", "--format", "specdoc", "--require", "spec/spec_helper.rb"]
23
+ end
24
+
25
+ end
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: 1.2.2
4
+ version: 2.4.2
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: 2008-11-06 00:00:00 -08:00
12
+ date: 2009-01-12 00:00:00 -08:00
13
13
  default_executable: commander
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,47 +22,87 @@ dependencies:
22
22
  version: 1.5.0
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
- name: hoe
25
+ name: echoe
26
26
  version_requirement:
27
27
  version_requirements: !ruby/object:Gem::Requirement
28
28
  requirements:
29
29
  - - ">="
30
30
  - !ruby/object:Gem::Version
31
- version: 1.8.2
31
+ version: "0"
32
32
  version:
33
- description: Commander is a small framework for creating a sub-command utility. For example a sub command would be 'git add' or 'git rm', where 'add' and 'rm' are sub commands.
34
- email:
35
- - tj@vision-media.ca
33
+ description: The complete solution for Ruby command-line executables
34
+ email: tj@vision-media.ca
36
35
  executables:
37
36
  - commander
38
37
  extensions: []
39
38
 
40
39
  extra_rdoc_files:
41
- - History.txt
42
- - Manifest.txt
43
- - README.txt
44
- files:
45
- - History.txt
46
- - Manifest.txt
47
- - README.txt
48
- - Rakefile
49
40
  - bin/commander
41
+ - lib/commander/command.rb
42
+ - lib/commander/core_ext/array.rb
43
+ - lib/commander/core_ext/kernel.rb
44
+ - lib/commander/core_ext/object.rb
45
+ - lib/commander/core_ext/string.rb
46
+ - lib/commander/core_ext.rb
47
+ - lib/commander/fileutils.rb
48
+ - lib/commander/help_formatters/base.rb
49
+ - lib/commander/help_formatters/terminal/command_help.erb
50
+ - lib/commander/help_formatters/terminal/help.erb
51
+ - lib/commander/help_formatters/terminal.rb
52
+ - lib/commander/help_formatters.rb
53
+ - lib/commander/import.rb
54
+ - lib/commander/runner.rb
55
+ - lib/commander/user_interaction.rb
56
+ - lib/commander/version.rb
50
57
  - lib/commander.rb
58
+ - README.rdoc
59
+ - tasks/docs.rake
60
+ - tasks/gemspec.rake
61
+ - tasks/spec.rake
62
+ files:
63
+ - bin/commander
64
+ - commander.gemspec
65
+ - History.rdoc
51
66
  - lib/commander/command.rb
52
- - lib/commander/commander.rb
53
- - lib/commander/help_generators.rb
54
- - lib/commander/help_generators/default.rb
55
- - lib/commander/manager.rb
67
+ - lib/commander/core_ext/array.rb
68
+ - lib/commander/core_ext/kernel.rb
69
+ - lib/commander/core_ext/object.rb
70
+ - lib/commander/core_ext/string.rb
71
+ - lib/commander/core_ext.rb
72
+ - lib/commander/fileutils.rb
73
+ - lib/commander/help_formatters/base.rb
74
+ - lib/commander/help_formatters/terminal/command_help.erb
75
+ - lib/commander/help_formatters/terminal/help.erb
76
+ - lib/commander/help_formatters/terminal.rb
77
+ - lib/commander/help_formatters.rb
78
+ - lib/commander/import.rb
79
+ - lib/commander/runner.rb
80
+ - lib/commander/user_interaction.rb
56
81
  - lib/commander/version.rb
57
- - spec/all_spec.rb
82
+ - lib/commander.rb
83
+ - Manifest
84
+ - Rakefile
85
+ - README.rdoc
58
86
  - spec/commander_spec.rb
59
- - spec/manager_spec.rb
87
+ - spec/help_formatter_spec.rb
88
+ - spec/spec_helper.rb
89
+ - tasks/docs.rake
90
+ - tasks/gemspec.rake
91
+ - tasks/spec.rake
92
+ - test/fileutils.rb
93
+ - test/progress.rb
94
+ - test/ui.rb
95
+ - Todo.rdoc
60
96
  has_rdoc: true
61
- homepage:
97
+ homepage: http://github.com/visionmedia/commander
62
98
  post_install_message:
63
99
  rdoc_options:
100
+ - --line-numbers
101
+ - --inline-source
102
+ - --title
103
+ - Commander
64
104
  - --main
65
- - README.txt
105
+ - README.rdoc
66
106
  require_paths:
67
107
  - lib
68
108
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -75,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
115
  requirements:
76
116
  - - ">="
77
117
  - !ruby/object:Gem::Version
78
- version: "0"
118
+ version: "1.2"
79
119
  version:
80
120
  requirements: []
81
121
 
@@ -83,6 +123,6 @@ rubyforge_project: commander
83
123
  rubygems_version: 1.2.0
84
124
  signing_key:
85
125
  specification_version: 2
86
- summary: Commander is a small framework for creating a sub-command utility
126
+ summary: The complete solution for Ruby command-line executables
87
127
  test_files: []
88
128
 
data/History.txt DELETED
@@ -1,48 +0,0 @@
1
-
2
- === 1.2.2 / 2008-11-06
3
-
4
- * 1 Bug Fix:
5
-
6
- * Forgot to add array.rb
7
-
8
- === 1.2.0 / 2008-11-06
9
-
10
- * 2 Major Enhancements:
11
-
12
- * Added paging ability (similar to 'less')
13
- * Added coloring to default help generator
14
-
15
- === 1.1.0 / 2008-11-06
16
-
17
- * 1 Major Enhancements:
18
-
19
- * Added dependency for Highline gem, which replaces Commander's user interaction lib
20
-
21
- === 1.0.4 / 2008-11-04
22
-
23
- * 1 Minor Enhancements:
24
-
25
- * Added support for --help and --version flags
26
-
27
- === 1.0.3 / 2008-11-01
28
-
29
- * 1 Bug Fix:
30
-
31
- * Typo causing the gem to fail build on github
32
-
33
- === 1.0.2 / 2008-11-01
34
-
35
- * 1 Minor Enhancements:
36
-
37
- * Added gemspec for github
38
-
39
- === 1.0.1 / 2008-10-31
40
-
41
- * 2 Minor Enhancements:
42
-
43
- * Added shebang line to commander init
44
- * Added require 'rubygems'
45
-
46
- === 1.0.0 / 2008-10-31
47
-
48
- * Initial release
data/Manifest.txt DELETED
@@ -1,17 +0,0 @@
1
- History.txt
2
- Manifest.txt
3
- README.txt
4
- Rakefile
5
- bin/commander
6
- commander.gemspec
7
- lib/commander.rb
8
- lib/commander/command.rb
9
- lib/commander/commander.rb
10
- lib/commander/core_ext/array.rb
11
- lib/commander/help_generators.rb
12
- lib/commander/help_generators/default.rb
13
- lib/commander/manager.rb
14
- lib/commander/version.rb
15
- spec/all_spec.rb
16
- spec/commander_spec.rb
17
- spec/manager_spec.rb
data/README.txt DELETED
@@ -1,76 +0,0 @@
1
-
2
- == DESCRIPTION:
3
-
4
- Commander is a small framework for creating a sub-command utility.
5
- For example a sub command would be 'git add' or 'git rm', where 'add' and
6
- 'rm' are sub commands.
7
-
8
- == FEATURES:
9
-
10
- * Sub-commands
11
- * Auto-generated help documentation globally and per sub-command
12
- * Simple syntax and implementation
13
- * Extensible help generators for various output formats
14
- * Use the 'commander' command to initialize a commander driven program
15
- * Dependent on highline for terminal interaction (ask, choose, etc)
16
-
17
- == USAGE:
18
-
19
- require 'commander'
20
-
21
- init_commander(
22
- :name => 'Commander',
23
- :version => Commander::VERSION,
24
- :description => 'Commander utility program.'
25
- )
26
-
27
- command :init do |c|
28
- c.syntax = 'commander init <filepath>'
29
- c.description = 'Initialize an empty file with a commander skeleton.'
30
- c.example 'Apply commander to a blank file.', 'commander init ./bin/my_executable'
31
- c.option('-r', '--recursive', 'Do something recursively') { puts "I am recursive." }
32
- c.option('-v', '--verbose', 'Do something verbosely') { puts "I am verbose." }
33
- c.when_called do |args|
34
- list = ask 'List some items:', Array
35
- # Do something with list
36
- end
37
- end
38
-
39
- == KNOWN ISSUES:
40
-
41
- * none
42
-
43
- == TODO:
44
-
45
- * look at newgem gem and copy the whole 'create ./path' verbose listing conventions
46
- * do testing for these apps like highline does with mock IO
47
- * look at highline examples and change commander commands to work without new-lines etc
48
- * more / better documentation
49
- * help generator options (such as large option description etc)
50
- * help generators should use erb
51
- * refactor
52
-
53
- == LICENSE:
54
-
55
- (The MIT License)
56
-
57
- Copyright (c) 2008 FIX
58
-
59
- Permission is hereby granted, free of charge, to any person obtaining
60
- a copy of this software and associated documentation files (the
61
- 'Software'), to deal in the Software without restriction, including
62
- without limitation the rights to use, copy, modify, merge, publish,
63
- distribute, sublicense, and/or sell copies of the Software, and to
64
- permit persons to whom the Software is furnished to do so, subject to
65
- the following conditions:
66
-
67
- The above copyright notice and this permission notice shall be
68
- included in all copies or substantial portions of the Software.
69
-
70
- THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
71
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
72
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
73
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
74
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
75
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
76
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,35 +0,0 @@
1
-
2
- require 'commander/version'
3
- require 'commander/command'
4
- require 'commander/manager'
5
- require 'commander/help_generators'
6
- require 'commander/core_ext/array'
7
- require 'optparse'
8
-
9
- module Commander
10
-
11
- def init_commander(options = {})
12
- Commander::Manager.instance options
13
- end
14
-
15
- def add_command(command, &block)
16
- _command = command
17
- command = Commander::Command.new(_command)
18
- yield command
19
- Commander::Manager.instance.add_command command
20
- end
21
- alias :command :add_command
22
-
23
- def get_command(command)
24
- Commander::Manager.instance.get_command command
25
- end
26
-
27
- def command_exists?(command)
28
- Commander::Manager.instance.include? command
29
- end
30
-
31
- def info(option)
32
- Commander::Manager.instance.info[option]
33
- end
34
- end
35
-