quickl 0.2.0 → 0.2.1

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.
Files changed (57) hide show
  1. data/CHANGELOG.md +23 -0
  2. data/Gemfile +2 -0
  3. data/Gemfile.lock +34 -0
  4. data/LICENCE.md +22 -0
  5. data/Manifest.txt +15 -0
  6. data/README.md +0 -25
  7. data/Rakefile +18 -32
  8. data/lib/quickl/command/builder.rb +18 -1
  9. data/lib/quickl/command/delegator.rb +8 -5
  10. data/lib/quickl/command/robustness.rb +4 -5
  11. data/lib/quickl/command/single.rb +1 -0
  12. data/lib/quickl/command.rb +12 -0
  13. data/lib/quickl/loader.rb +0 -0
  14. data/lib/quickl/version.rb +14 -0
  15. data/lib/quickl.rb +3 -4
  16. data/quickl.gemspec +178 -27
  17. data/quickl.noespec +58 -0
  18. data/spec/command/command_building_spec.rb +16 -0
  19. data/spec/command/command_name_spec.rb +16 -0
  20. data/spec/command/documentation_spec.rb +23 -0
  21. data/spec/command/overview_spec.rb +14 -0
  22. data/spec/command/requester_spec.rb +16 -0
  23. data/spec/command/robustness/valid_read_file_spec.rb +62 -0
  24. data/spec/command/run_spec.rb +22 -0
  25. data/spec/command/subcommand_by_name_spec.rb +15 -0
  26. data/spec/command/subcommands_spec.rb +24 -0
  27. data/spec/command/usage_spec.rb +16 -0
  28. data/spec/mini_client.rb +96 -0
  29. data/spec/naming/command2module_spec.rb +17 -0
  30. data/spec/naming/module2command_spec.rb +21 -0
  31. data/spec/quickl_spec.rb +8 -0
  32. data/spec/ruby_tools/class_unqualified_name_spec.rb +28 -0
  33. data/spec/ruby_tools/extract_file_rdoc_spec.rb +28 -0
  34. data/spec/ruby_tools/fixtures/RubyTools.rdoc +12 -0
  35. data/spec/ruby_tools/fixtures/Utils.rdoc +3 -0
  36. data/spec/ruby_tools/fixtures.rb +27 -0
  37. data/spec/ruby_tools/optional_args_block_call_spec.rb +37 -0
  38. data/spec/ruby_tools/parent_module_spec.rb +23 -0
  39. data/spec/spec_helper.rb +4 -0
  40. data/tasks/debug_mail.rake +78 -0
  41. data/tasks/debug_mail.txt +13 -0
  42. data/tasks/gem.rake +68 -0
  43. data/tasks/spec_test.rake +79 -0
  44. data/tasks/unit_test.rake +77 -0
  45. data/tasks/yard.rake +51 -0
  46. metadata +150 -105
  47. data/examples/delegator/README.md +0 -86
  48. data/examples/delegator/bin/delegator +0 -9
  49. data/examples/delegator/lib/delegator.rb +0 -41
  50. data/examples/delegator/lib/hello_world.rb +0 -39
  51. data/examples/delegator/lib/help.rb +0 -24
  52. data/examples/delegator/test/delegator_test.rb +0 -68
  53. data/examples/hello/README.md +0 -74
  54. data/examples/hello/hello +0 -57
  55. data/examples/hello/hello_test.rb +0 -65
  56. data/examples/helper.rb +0 -6
  57. data/templates/single.erb +0 -40
@@ -0,0 +1,79 @@
1
+ # Installs a rake task for for running examples written using rspec.
2
+ #
3
+ # This file installs the 'rake spec_test' (aliased as 'rake spec') as well as
4
+ # extends 'rake test' to run spec tests, if any. It is automatically generated
5
+ # by Noe from your .noespec file, and should therefore be configured there,
6
+ # under the variables/rake_tasks/spec_test entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # spec_test:
11
+ # pattern: spec/**/*_spec.rb
12
+ # verbose: true
13
+ # rspec_opts: [--color, --backtrace]
14
+ # ...
15
+ #
16
+ # If you have specific needs requiring manual intervention on this file,
17
+ # don't forget to set safe-override to false in your noe specification:
18
+ #
19
+ # template-info:
20
+ # manifest:
21
+ # tasks/spec_test.rake:
22
+ # safe-override: false
23
+ #
24
+ # This file has been written to conform to RSpec v2.4.0. More information about
25
+ # rspec and options of the rake task defined below can be found on
26
+ # http://relishapp.com/rspec
27
+ #
28
+ begin
29
+ require "rspec/core/rake_task"
30
+ desc "Run RSpec code examples"
31
+ RSpec::Core::RakeTask.new(:spec_test) do |t|
32
+ # Glob pattern to match files.
33
+ t.pattern = "spec/**/*_spec.rb"
34
+
35
+ # By default, if there is a Gemfile, the generated command will include
36
+ # 'bundle exec'. Set this to true to ignore the presence of a Gemfile,
37
+ # and not add 'bundle exec' to the command.
38
+ t.skip_bundler = false
39
+
40
+ # Name of Gemfile to use
41
+ t.gemfile = "Gemfile"
42
+
43
+ # Whether or not to fail Rake when an error occurs (typically when
44
+ # examples fail).
45
+ t.fail_on_error = true
46
+
47
+ # A message to print to stderr when there are failures.
48
+ t.failure_message = nil
49
+
50
+ # Use verbose output. If this is set to true, the task will print the
51
+ # executed spec command to stdout.
52
+ t.verbose = true
53
+
54
+ # Use rcov for code coverage?
55
+ t.rcov = false
56
+
57
+ # Path to rcov.
58
+ t.rcov_path = "rcov"
59
+
60
+ # Command line options to pass to rcov. See 'rcov --help' about this
61
+ t.rcov_opts = []
62
+
63
+ # Command line options to pass to ruby. See 'ruby --help' about this
64
+ t.ruby_opts = []
65
+
66
+ # Path to rspec
67
+ t.rspec_path = "rspec"
68
+
69
+ # Command line options to pass to rspec. See 'rspec --help' about this
70
+ t.rspec_opts = ["--color", "--backtrace"]
71
+ end
72
+ rescue LoadError => ex
73
+ task :spec_test do
74
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
75
+ end
76
+ ensure
77
+ task :spec => [:spec_test]
78
+ task :test => [:spec_test]
79
+ end
@@ -0,0 +1,77 @@
1
+ # Installs a rake task for for running unit tests.
2
+ #
3
+ # This file installs the 'rake unit_test' and extends 'rake test' to run unit
4
+ # tests, if any. It is automatically generated by Noe from your .noespec file,
5
+ # and should therefore be configured there, under the variables/rake_tasks/unit_test
6
+ # entry, as illustrated below:
7
+ #
8
+ # variables:
9
+ # rake_tasks:
10
+ # unit_test:
11
+ # pattern: test/test*.rb
12
+ # verbose: false
13
+ # warning: false
14
+ # ...
15
+ #
16
+ # If you have specific needs requiring manual intervention on this file,
17
+ # don't forget to set safe-override to false in your noe specification:
18
+ #
19
+ # template-info:
20
+ # manifest:
21
+ # tasks/unit_test.rake:
22
+ # safe-override: false
23
+ #
24
+ # More info about the TestTask and its options can be found on
25
+ # http://rake.rubyforge.org/classes/Rake/TestTask.html
26
+ #
27
+ begin
28
+ require 'rake/testtask'
29
+ desc "Run unit tests"
30
+ Rake::TestTask.new(:unit_test) do |t|
31
+
32
+ # List of directories to added to $LOAD_PATH before running the
33
+ # tests. (default is 'lib')
34
+ t.libs = ["lib"]
35
+
36
+ # True if verbose test output desired. (default is false)
37
+ t.verbose = false
38
+
39
+ # Test options passed to the test suite. An explicit TESTOPTS=opts
40
+ # on the command line will override this. (default is NONE)
41
+ t.options = nil
42
+
43
+ # Request that the tests be run with the warning flag set.
44
+ # E.g. warning=true implies "ruby -w" used to run the tests.
45
+ t.warning = false
46
+
47
+ # Glob pattern to match test files. (default is 'test/test*.rb')
48
+ t.pattern = "examples/**/*_test.rb"
49
+
50
+ # Style of test loader to use. Options are:
51
+ #
52
+ # * :rake -- Rake provided test loading script (default).
53
+ # * :testrb -- Ruby provided test loading script.
54
+ # * :direct -- Load tests using command line loader.
55
+ #
56
+ t.loader = :rake
57
+
58
+ # Array of commandline options to pass to ruby when running test
59
+ # loader.
60
+ t.ruby_opts = []
61
+
62
+ # Explicitly define the list of test files to be included in a
63
+ # test. +list+ is expected to be an array of file names (a
64
+ # FileList is acceptable). If both +pattern+ and +test_files+ are
65
+ # used, then the list of test files is the union of the two.
66
+ t.test_files = nil
67
+
68
+ end
69
+ rescue LoadError => ex
70
+ task :unit_test do
71
+ abort 'rspec is not available. In order to run spec, you must: gem install rspec'
72
+ end
73
+ ensure
74
+ desc "Run all tests"
75
+ task :test => [:unit_test]
76
+ end
77
+
data/tasks/yard.rake ADDED
@@ -0,0 +1,51 @@
1
+ # Installs a rake task to generate API documentation using yard.
2
+ #
3
+ # This file installs the 'rake yard' task. It is automatically generated by Noe from
4
+ # your .noespec file, and should therefore be configured there, under the
5
+ # variables/rake_tasks/yard entry, as illustrated below:
6
+ #
7
+ # variables:
8
+ # rake_tasks:
9
+ # yard:
10
+ # files: lib/**/*.rb
11
+ # options: []
12
+ # ...
13
+ #
14
+ # If you have specific needs requiring manual intervention on this file,
15
+ # don't forget to set safe-override to false in your noe specification:
16
+ #
17
+ # template-info:
18
+ # manifest:
19
+ # tasks/yard.rake:
20
+ # safe-override: false
21
+ #
22
+ # This file has been written to conform to yard v0.6.4. More information about
23
+ # yard and the rake task installed below can be found on http://yardoc.org/
24
+ #
25
+ begin
26
+ require "yard"
27
+ desc "Generate yard documentation"
28
+ YARD::Rake::YardocTask.new(:yard) do |t|
29
+ # Array of options passed to yardoc commandline. See 'yardoc --help' about this
30
+ t.options = ["--output-dir", "doc/api", "-", "README.md", "CHANGELOG.md", "LICENCE.md"]
31
+
32
+ # Array of ruby source files (and any extra documentation files
33
+ # separated by '-')
34
+ t.files = ["lib/**/*.rb"]
35
+
36
+ # A proc to call before running the task
37
+ # t.before = proc{ }
38
+
39
+ # A proc to call after running the task
40
+ # r.after = proc{ }
41
+
42
+ # An optional lambda to run against all objects being generated.
43
+ # Any object that the lambda returns false for will be excluded
44
+ # from documentation.
45
+ # t.verifier = lambda{|obj| true}
46
+ end
47
+ rescue LoadError
48
+ task :yard do
49
+ abort 'yard is not available. In order to run yard, you must: gem install yard'
50
+ end
51
+ end
metadata CHANGED
@@ -1,152 +1,197 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: quickl
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Bernard Lambeau
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-01-10 00:00:00 +01:00
12
+ date: 2011-06-19 00:00:00.000000000 +02:00
18
13
  default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
21
16
  name: rake
17
+ requirement: &83708950 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.8.7
23
+ type: :development
22
24
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
25
+ version_requirements: *83708950
26
+ - !ruby/object:Gem::Dependency
27
+ name: bundler
28
+ requirement: &83708460 !ruby/object:Gem::Requirement
24
29
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
31
34
  type: :development
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: rspec
35
35
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
36
+ version_requirements: *83708460
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ requirement: &83707960 !ruby/object:Gem::Requirement
37
40
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 2
43
- - 4
44
- - 0
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
45
44
  version: 2.4.0
46
45
  type: :development
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: yard
50
46
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
47
+ version_requirements: *83707960
48
+ - !ruby/object:Gem::Dependency
49
+ name: yard
50
+ requirement: &83707400 !ruby/object:Gem::Requirement
52
51
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 0
58
- - 6
59
- - 4
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
60
55
  version: 0.6.4
61
56
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
57
+ prerelease: false
58
+ version_requirements: *83707400
59
+ - !ruby/object:Gem::Dependency
64
60
  name: bluecloth
61
+ requirement: &83706930 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ~>
65
+ - !ruby/object:Gem::Version
66
+ version: 2.0.9
67
+ type: :development
65
68
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
69
+ version_requirements: *83706930
70
+ - !ruby/object:Gem::Dependency
71
+ name: wlang
72
+ requirement: &83706160 !ruby/object:Gem::Requirement
67
73
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- segments:
72
- - 0
73
- - 6
74
- - 4
75
- version: 0.6.4
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.10.1
76
78
  type: :development
77
- version_requirements: *id004
78
- description: Generate Ruby command line apps quickly
79
- email: blambeau@gmail.com
80
- executables:
79
+ prerelease: false
80
+ version_requirements: *83706160
81
+ description: ! "Quickl helps you creating commandline ruby programs. From simple commands
82
+ \nwith options to complex delegators with subcommands, global and local \noptions."
83
+ email:
84
+ - blambeau@gmail.com
85
+ executables:
81
86
  - quickl
82
87
  extensions: []
83
-
84
- extra_rdoc_files:
88
+ extra_rdoc_files:
85
89
  - README.md
86
- files:
90
+ - CHANGELOG.md
91
+ - LICENCE.md
92
+ files:
93
+ - quickl.gemspec
94
+ - quickl.noespec
95
+ - CHANGELOG.md
96
+ - Gemfile
97
+ - Gemfile.lock
98
+ - bin/quickl
99
+ - lib/quickl.rb
100
+ - lib/quickl/command/single.rb
87
101
  - lib/quickl/command/builder.rb
88
- - lib/quickl/command/delegator.rb
89
102
  - lib/quickl/command/options.rb
90
103
  - lib/quickl/command/robustness.rb
91
- - lib/quickl/command/single.rb
92
- - lib/quickl/command.rb
104
+ - lib/quickl/command/delegator.rb
105
+ - lib/quickl/naming.rb
93
106
  - lib/quickl/errors.rb
107
+ - lib/quickl/loader.rb
94
108
  - lib/quickl/ext/object.rb
95
- - lib/quickl/naming.rb
96
109
  - lib/quickl/ruby_tools.rb
97
- - lib/quickl.rb
98
- - examples/delegator/bin/delegator
99
- - examples/delegator/lib/delegator.rb
100
- - examples/delegator/lib/hello_world.rb
101
- - examples/delegator/lib/help.rb
102
- - examples/delegator/README.md
103
- - examples/delegator/test/delegator_test.rb
104
- - examples/hello/hello
105
- - examples/hello/hello_test.rb
106
- - examples/hello/README.md
107
- - examples/helper.rb
108
- - templates/single.erb
109
- - bin/quickl
110
- - quickl.gemspec
110
+ - lib/quickl/command.rb
111
+ - lib/quickl/version.rb
112
+ - LICENCE.md
113
+ - Manifest.txt
111
114
  - Rakefile
112
115
  - README.md
113
- - CHANGELOG.md
116
+ - spec/spec_helper.rb
117
+ - spec/command/usage_spec.rb
118
+ - spec/command/command_name_spec.rb
119
+ - spec/command/subcommands_spec.rb
120
+ - spec/command/requester_spec.rb
121
+ - spec/command/subcommand_by_name_spec.rb
122
+ - spec/command/run_spec.rb
123
+ - spec/command/robustness/valid_read_file_spec.rb
124
+ - spec/command/overview_spec.rb
125
+ - spec/command/documentation_spec.rb
126
+ - spec/command/command_building_spec.rb
127
+ - spec/mini_client.rb
128
+ - spec/ruby_tools/fixtures.rb
129
+ - spec/ruby_tools/class_unqualified_name_spec.rb
130
+ - spec/ruby_tools/extract_file_rdoc_spec.rb
131
+ - spec/ruby_tools/parent_module_spec.rb
132
+ - spec/ruby_tools/optional_args_block_call_spec.rb
133
+ - spec/ruby_tools/fixtures/RubyTools.rdoc
134
+ - spec/ruby_tools/fixtures/Utils.rdoc
135
+ - spec/quickl_spec.rb
136
+ - spec/naming/module2command_spec.rb
137
+ - spec/naming/command2module_spec.rb
138
+ - tasks/debug_mail.rake
139
+ - tasks/yard.rake
140
+ - tasks/gem.rake
141
+ - tasks/spec_test.rake
142
+ - tasks/unit_test.rake
143
+ - tasks/debug_mail.txt
114
144
  has_rdoc: true
115
145
  homepage: http://github.com/blambeau/quickl
116
146
  licenses: []
117
-
118
147
  post_install_message:
119
- rdoc_options:
120
- - --line-numbers
121
- - --inline-source
122
- - --title
123
- - Quickl
124
- - --main
125
- - Quickl
126
- require_paths:
148
+ rdoc_options: []
149
+ require_paths:
127
150
  - lib
128
- required_ruby_version: !ruby/object:Gem::Requirement
151
+ required_ruby_version: !ruby/object:Gem::Requirement
129
152
  none: false
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- segments:
153
+ requirements:
154
+ - - ! '>='
155
+ - !ruby/object:Gem::Version
156
+ version: '0'
157
+ segments:
134
158
  - 0
135
- version: "0"
136
- required_rubygems_version: !ruby/object:Gem::Requirement
159
+ hash: 178817935
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
137
161
  none: false
138
- requirements:
139
- - - ">="
140
- - !ruby/object:Gem::Version
141
- segments:
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ segments:
142
167
  - 0
143
- version: "0"
168
+ hash: 178817935
144
169
  requirements: []
145
-
146
170
  rubyforge_project:
147
- rubygems_version: 1.3.7
171
+ rubygems_version: 1.6.2
148
172
  signing_key:
149
173
  specification_version: 3
150
- summary: Generate Ruby command line apps quickly
151
- test_files: []
152
-
174
+ summary: Helper to create commandline ruby programs
175
+ test_files:
176
+ - spec/spec_helper.rb
177
+ - spec/command/usage_spec.rb
178
+ - spec/command/command_name_spec.rb
179
+ - spec/command/subcommands_spec.rb
180
+ - spec/command/requester_spec.rb
181
+ - spec/command/subcommand_by_name_spec.rb
182
+ - spec/command/run_spec.rb
183
+ - spec/command/robustness/valid_read_file_spec.rb
184
+ - spec/command/overview_spec.rb
185
+ - spec/command/documentation_spec.rb
186
+ - spec/command/command_building_spec.rb
187
+ - spec/mini_client.rb
188
+ - spec/ruby_tools/fixtures.rb
189
+ - spec/ruby_tools/class_unqualified_name_spec.rb
190
+ - spec/ruby_tools/extract_file_rdoc_spec.rb
191
+ - spec/ruby_tools/parent_module_spec.rb
192
+ - spec/ruby_tools/optional_args_block_call_spec.rb
193
+ - spec/ruby_tools/fixtures/RubyTools.rdoc
194
+ - spec/ruby_tools/fixtures/Utils.rdoc
195
+ - spec/quickl_spec.rb
196
+ - spec/naming/module2command_spec.rb
197
+ - spec/naming/command2module_spec.rb
@@ -1,86 +0,0 @@
1
- # Quickl example: delegator
2
-
3
- This example shows how to create delegator commands. Delegators are commands
4
- that delegate the actual execution to sub commands (well known example is
5
- 'git'). A delegator command typically has a signature like:
6
-
7
- delegator [main options] COMMAND [cmd options] ARGS...
8
-
9
- ## Structure
10
-
11
- The structure for delegator commands is as follows:
12
-
13
- #
14
- # Main command overview
15
- #
16
- # SYNOPSIS
17
- # Usage: #{command_name} [main options] COMMAND [cmd options] ARGS...
18
- #
19
- # OPTIONS
20
- # #{sumarized_options}
21
- #
22
- # COMMANDS
23
- # #{summarized_commands}
24
- #
25
- # DESCRIPTION
26
- # Long description here...
27
- #
28
- # See '#{command_name} help COMMAND' for more information on a specific command.
29
- #
30
- class DelegatorCommand < Quickl::Delegator(__FILE__, __LINE__)
31
-
32
- # install options below
33
- options do |opt|
34
- # _opt_ is an OptionParser instance
35
- end
36
-
37
- #
38
- # Sub command overview
39
- #
40
- # ...
41
- #
42
- class SubCommand1 < Quickl::Command(__FILE__, __LINE__)
43
-
44
- # [ ... ]
45
-
46
- end
47
-
48
- #
49
- # Sub command overview
50
- #
51
- # ...
52
- #
53
- class SubCommand2 < Quickl::Command(__FILE__, __LINE__)
54
-
55
- # [ ... ]
56
-
57
- end
58
-
59
- end
60
-
61
- # To run the command, typically in a bin/simple_command
62
- # shell file
63
- DelegatorCommand.run(ARGV)
64
-
65
-
66
- ## Example
67
-
68
- Try the following:
69
-
70
- ./delegator
71
- # => [ ... complete help with subcommands summary ... ]
72
-
73
- ./delegator --help
74
- # => [ ... complete help with subcommands summary ... ]
75
-
76
- ./delegator help
77
- # => [ ... complete help with subcommands summary ... ]
78
-
79
- ./delegator help hello-world
80
- # => [ ... help of hello-world's subcommand ... ]
81
-
82
- ./delegator hello-world bob
83
- # => Hello bob!
84
-
85
- ./hello_world --capitalize bob
86
- # => Hello Bob!
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.expand_path('../../../helper', __FILE__)
3
-
4
- # Load the delegate tool
5
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
6
- require "delegator"
7
-
8
- # Run the command
9
- Delegator.run(ARGV, __FILE__)
@@ -1,41 +0,0 @@
1
- #
2
- # Delegate execution to a sub command
3
- #
4
- # SYNOPSIS
5
- # #{program_name} [--version] [--help] [--output=...] COMMAND [cmd opts] ARGS...
6
- #
7
- # OPTIONS
8
- # #{summarized_options}
9
- #
10
- # COMMANDS
11
- # #{summarized_subcommands}
12
- #
13
- # DESCRIPTION
14
- # This example shows how to write a delegator command, that is, a
15
- # command which delegates to a subcommand
16
- #
17
- # See '#{program_name} help COMMAND' for more information on a specific command.
18
- #
19
- class Delegator < Quickl::Delegator(__FILE__, __LINE__)
20
-
21
- # Single command version
22
- VERSION = "0.1.0"
23
-
24
- # Install options
25
- options do |opt|
26
-
27
- # Show the help and exit
28
- opt.on_tail("--help", "Show help") do
29
- raise Quickl::Help
30
- end
31
-
32
- # Show version and exit
33
- opt.on_tail("--version", "Show version") do
34
- raise Quickl::Exit, "#{program_name} #{VERSION} (c) 2010, Bernard Lambeau"
35
- end
36
-
37
- end
38
-
39
- end # class Delegator
40
- require "help"
41
- require "hello_world"
@@ -1,39 +0,0 @@
1
- class Delegator
2
- #
3
- # Say hello
4
- #
5
- # SYNOPSIS
6
- # #{program_name} #{command_name} [--capitalize] [WHO]
7
- #
8
- # OPTIONS
9
- # #{summarized_options}
10
- #
11
- # DESCRIPTION
12
- # Without any argument, says hello to the world. When a single argument
13
- # is given says hello to the user.
14
- #
15
- class HelloWorld < Quickl::Command(__FILE__, __LINE__)
16
-
17
- # Install command options
18
- options do |opt|
19
-
20
- # Capitalize user name?
21
- opt.on("--capitalize", "-c", "Capitalize user name") do
22
- @capitalize = true
23
- end
24
-
25
- end
26
-
27
- # Execute the command on some arguments
28
- def execute(args)
29
- if args.size <= 1
30
- name = args.first || "world"
31
- name = name.capitalize if @capitalize
32
- puts "Hello #{name}!"
33
- else
34
- raise Quickl::InvalidArgument, "Useless arguments: #{args.join(' ')}"
35
- end
36
- end
37
-
38
- end # class HelloWorld
39
- end # class Delegator