clone 1.0.0.alpha → 1.0.0.beta

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 (189) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -1
  3. data/Gemfile +1 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +22 -1
  6. data/VERSION +1 -1
  7. data/bin/clone +7 -0
  8. data/clone.gemspec +4 -0
  9. data/docs/readme +16 -0
  10. data/docs/readme.txt +5 -0
  11. data/lib/clone.rb +13 -2
  12. data/lib/clone/config/config.rb +19 -0
  13. data/lib/clone/config/config.yml +22 -0
  14. data/lib/clone/config/default_config.yml +20 -0
  15. data/lib/clone/config/require.rb +3 -0
  16. data/lib/clone/config/version.rb +10 -0
  17. data/lib/clone/config/yml.rb +22 -0
  18. data/lib/clone/config/z_defaults.rb +28 -0
  19. data/lib/clone/generator/engine.rb +581 -0
  20. data/lib/clone/generator/terminal.rb +104 -0
  21. data/lib/clone/helpers/helper_methods.rb +251 -0
  22. data/lib/clone/helpers/local_methods.rb +150 -0
  23. data/lib/clone/helpers/require.rb +37 -0
  24. data/module/Marshal.4.8 +0 -0
  25. data/module/Marshal.4.8.Z +0 -0
  26. data/module/gems/commander-4.1.3/.gitignore +6 -0
  27. data/module/gems/commander-4.1.3/.travis.yml +11 -0
  28. data/module/gems/commander-4.1.3/DEVELOPMENT +15 -0
  29. data/module/gems/commander-4.1.3/Gemfile +3 -0
  30. data/module/gems/commander-4.1.3/History.rdoc +345 -0
  31. data/module/gems/commander-4.1.3/Manifest +38 -0
  32. data/module/gems/commander-4.1.3/README.rdoc +375 -0
  33. data/module/gems/commander-4.1.3/Rakefile +10 -0
  34. data/module/gems/commander-4.1.3/bin/commander +55 -0
  35. data/module/gems/commander-4.1.3/commander.gemspec +26 -0
  36. data/module/gems/commander-4.1.3/lib/commander.rb +32 -0
  37. data/module/gems/commander-4.1.3/lib/commander/blank.rb +8 -0
  38. data/module/gems/commander-4.1.3/lib/commander/command.rb +213 -0
  39. data/module/gems/commander-4.1.3/lib/commander/core_ext.rb +3 -0
  40. data/module/gems/commander-4.1.3/lib/commander/core_ext/array.rb +26 -0
  41. data/module/gems/commander-4.1.3/lib/commander/core_ext/object.rb +11 -0
  42. data/module/gems/commander-4.1.3/lib/commander/delegates.rb +13 -0
  43. data/module/gems/commander-4.1.3/lib/commander/help_formatters.rb +8 -0
  44. data/module/gems/commander-4.1.3/lib/commander/help_formatters/base.rb +18 -0
  45. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal.rb +20 -0
  46. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/command_help.erb +35 -0
  47. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal/help.erb +36 -0
  48. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact.rb +12 -0
  49. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/command_help.erb +27 -0
  50. data/module/gems/commander-4.1.3/lib/commander/help_formatters/terminal_compact/help.erb +29 -0
  51. data/module/gems/commander-4.1.3/lib/commander/import.rb +10 -0
  52. data/module/gems/commander-4.1.3/lib/commander/platform.rb +8 -0
  53. data/module/gems/commander-4.1.3/lib/commander/runner.rb +411 -0
  54. data/module/gems/commander-4.1.3/lib/commander/user_interaction.rb +521 -0
  55. data/module/gems/commander-4.1.3/lib/commander/version.rb +3 -0
  56. data/module/gems/commander-4.1.3/spec/command_spec.rb +157 -0
  57. data/module/gems/commander-4.1.3/spec/core_ext/array_spec.rb +20 -0
  58. data/module/gems/commander-4.1.3/spec/core_ext/object_spec.rb +21 -0
  59. data/module/gems/commander-4.1.3/spec/help_formatters/terminal_spec.rb +67 -0
  60. data/module/gems/commander-4.1.3/spec/runner_spec.rb +526 -0
  61. data/module/gems/commander-4.1.3/spec/spec_helper.rb +59 -0
  62. data/module/gems/commander-4.1.3/spec/ui_spec.rb +30 -0
  63. data/module/gems/hello.rb +1 -0
  64. data/module/gems/highline-1.6.19/.gitignore +2 -0
  65. data/module/gems/highline-1.6.19/AUTHORS +3 -0
  66. data/module/gems/highline-1.6.19/CHANGELOG +346 -0
  67. data/module/gems/highline-1.6.19/COPYING +340 -0
  68. data/module/gems/highline-1.6.19/INSTALL +55 -0
  69. data/module/gems/highline-1.6.19/LICENSE +7 -0
  70. data/module/gems/highline-1.6.19/README.rdoc +63 -0
  71. data/module/gems/highline-1.6.19/Rakefile +50 -0
  72. data/module/gems/highline-1.6.19/TODO +6 -0
  73. data/module/gems/highline-1.6.19/examples/ansi_colors.rb +38 -0
  74. data/module/gems/highline-1.6.19/examples/asking_for_arrays.rb +18 -0
  75. data/module/gems/highline-1.6.19/examples/basic_usage.rb +75 -0
  76. data/module/gems/highline-1.6.19/examples/color_scheme.rb +32 -0
  77. data/module/gems/highline-1.6.19/examples/get_character.rb +12 -0
  78. data/module/gems/highline-1.6.19/examples/limit.rb +12 -0
  79. data/module/gems/highline-1.6.19/examples/menus.rb +65 -0
  80. data/module/gems/highline-1.6.19/examples/overwrite.rb +19 -0
  81. data/module/gems/highline-1.6.19/examples/page_and_wrap.rb +322 -0
  82. data/module/gems/highline-1.6.19/examples/password.rb +7 -0
  83. data/module/gems/highline-1.6.19/examples/repeat_entry.rb +21 -0
  84. data/module/gems/highline-1.6.19/examples/trapping_eof.rb +22 -0
  85. data/module/gems/highline-1.6.19/examples/using_readline.rb +17 -0
  86. data/module/gems/highline-1.6.19/highline.gemspec +37 -0
  87. data/module/gems/highline-1.6.19/lib/highline.rb +1012 -0
  88. data/module/gems/highline-1.6.19/lib/highline/color_scheme.rb +134 -0
  89. data/module/gems/highline-1.6.19/lib/highline/compatibility.rb +16 -0
  90. data/module/gems/highline-1.6.19/lib/highline/import.rb +41 -0
  91. data/module/gems/highline-1.6.19/lib/highline/menu.rb +398 -0
  92. data/module/gems/highline-1.6.19/lib/highline/question.rb +475 -0
  93. data/module/gems/highline-1.6.19/lib/highline/simulate.rb +48 -0
  94. data/module/gems/highline-1.6.19/lib/highline/string_extensions.rb +131 -0
  95. data/module/gems/highline-1.6.19/lib/highline/style.rb +181 -0
  96. data/module/gems/highline-1.6.19/lib/highline/system_extensions.rb +222 -0
  97. data/module/gems/highline-1.6.19/setup.rb +1360 -0
  98. data/module/gems/highline-1.6.19/site/.cvsignore +1 -0
  99. data/module/gems/highline-1.6.19/site/highline.css +65 -0
  100. data/module/gems/highline-1.6.19/site/images/logo.png +0 -0
  101. data/module/gems/highline-1.6.19/site/index.html +58 -0
  102. data/module/gems/highline-1.6.19/test/string_methods.rb +32 -0
  103. data/module/gems/highline-1.6.19/test/tc_color_scheme.rb +96 -0
  104. data/module/gems/highline-1.6.19/test/tc_highline.rb +1128 -0
  105. data/module/gems/highline-1.6.19/test/tc_import.rb +52 -0
  106. data/module/gems/highline-1.6.19/test/tc_menu.rb +439 -0
  107. data/module/gems/highline-1.6.19/test/tc_string_extension.rb +20 -0
  108. data/module/gems/highline-1.6.19/test/tc_string_highline.rb +38 -0
  109. data/module/gems/highline-1.6.19/test/tc_style.rb +567 -0
  110. data/module/gems/highline-1.6.19/test/ts_all.rb +16 -0
  111. data/module/latest_specs.4.8 +0 -0
  112. data/module/latest_specs.4.8.gz +0 -0
  113. data/module/prerelease_specs.4.8 +0 -0
  114. data/module/prerelease_specs.4.8.gz +0 -0
  115. data/module/specs.4.8 +0 -0
  116. data/module/specs.4.8.gz +0 -0
  117. data/samples/blather/restlike/Gemfile +4 -0
  118. data/samples/blather/restlike/cmd.yml +1 -0
  119. data/samples/blather/restlike/lib/blather.rb +9 -0
  120. data/samples/blather/restlike/lib/blather/dsl/api.rb +78 -0
  121. data/samples/blather/restlike/lib/blather/dsl/call.rb +13 -0
  122. data/samples/blather/restlike/lib/blather/dsl/client.rb +58 -0
  123. data/samples/blather/restlike/lib/blather/dsl/config.rb +11 -0
  124. data/samples/blather/restlike/lib/blather/dsl/extraDSL.rb +163 -0
  125. data/samples/blather/restlike/lib/blather/meta/require.rb +8 -0
  126. data/samples/blather/restlike/lib/blather/meta/xmpp.yml +5 -0
  127. data/samples/blather/restlike/lib/blather/vendors/xmpp_default.rb +27 -0
  128. data/samples/blather/restlike/readme +2 -0
  129. data/samples/grape/init/Gemfile +2 -0
  130. data/samples/grape/init/cmd.yml +3 -0
  131. data/samples/grape/init/config.ru +2 -0
  132. data/samples/grape/init/docs/grape/documentation.txt +939 -0
  133. data/samples/grape/init/docs/grape/generate_rest_routes.rb +37 -0
  134. data/samples/grape/init/docs/grape/ls_routes.rb +31 -0
  135. data/samples/grape/init/lib/grape.rb +4 -0
  136. data/samples/grape/init/lib/grape/meta/subclasses.rb +20 -0
  137. data/samples/grape/init/lib/grape/xpath/app.rb +30 -0
  138. data/samples/grape/init/lib/grape/xpath/ruotes.rb +6 -0
  139. data/samples/grape/init/readme +1 -0
  140. data/samples/grape/readme +29 -0
  141. data/samples/grape/vendor/lib/grape/vendors/v1/rest.rb +57 -0
  142. data/samples/mongoid/cmd.yml +1 -0
  143. data/samples/mongoid/init/Gemfile +3 -0
  144. data/samples/mongoid/init/cmd.yml +2 -0
  145. data/samples/mongoid/init/docs/mongoid/ModelsRelations.rb +11 -0
  146. data/samples/mongoid/init/docs/mongoid/documents.xls +0 -0
  147. data/samples/mongoid/init/docs/mongoid/generate_modelsToDocs.rb +25 -0
  148. data/samples/mongoid/init/docs/mongoid/modelsToDocs.rb +25 -0
  149. data/samples/mongoid/init/docs/mongoid/relations.txt +1354 -0
  150. data/samples/mongoid/init/lib/mongoid.rb +44 -0
  151. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_CRUD.rb +446 -0
  152. data/samples/mongoid/init/lib/mongoid/dsl/extraDSL_MP.rb +517 -0
  153. data/samples/mongoid/init/lib/mongoid/dsl/init.rb +37 -0
  154. data/samples/mongoid/init/lib/mongoid/dsl/params.rb +67 -0
  155. data/samples/mongoid/init/lib/mongoid/meta/banned.rb +147 -0
  156. data/samples/mongoid/init/lib/mongoid/meta/control.yml +13 -0
  157. data/samples/mongoid/init/lib/mongoid/meta/mongoid.yml +6 -0
  158. data/samples/mongoid/init/lib/mongoid/meta/mpatch.rb +14 -0
  159. data/samples/mongoid/model/lib/mongoid/models/model.rb +28 -0
  160. data/samples/mongoid/readme +33 -0
  161. data/samples/rack/init/Gemfile +10 -0
  162. data/samples/rack/init/cmd.yml +2 -0
  163. data/samples/rack/init/config.ru +1 -0
  164. data/samples/rack/init/docs/rack/rake introducing.txt +60 -0
  165. data/samples/rack/init/docs/rack/webservers/Thin +43 -0
  166. data/samples/rack/init/docs/rack/webservers/ebb +72 -0
  167. data/samples/rack/init/docs/rack/webservers/fcgi +103 -0
  168. data/samples/rack/init/docs/rack/webservers/mongrel +74 -0
  169. data/samples/rack/init/docs/rack/webservers/passenger +37 -0
  170. data/samples/rack/init/docs/rack/webservers/scgi +188 -0
  171. data/samples/rack/init/lib/rack.rb +1 -0
  172. data/samples/rack/init/lib/rack/meta/webserver/thin.rb +45 -0
  173. data/samples/rack/init/lib/rack/meta/webserver/thin.yml +6 -0
  174. data/samples/rack/init/server.rb +0 -0
  175. data/samples/rack/readme +13 -0
  176. data/samples/rest_client/init/Gemfile +5 -0
  177. data/samples/rest_client/init/boot.rb +2 -0
  178. data/samples/rest_client/init/cmd.yml +1 -0
  179. data/samples/rest_client/init/config/rest_client/defaults.rb +16 -0
  180. data/samples/rest_client/init/docs/rest_client/simple overlook +251 -0
  181. data/samples/rest_client/init/test/rest_client/rest_dsl.rb +5 -0
  182. data/samples/rest_client/readme +7 -0
  183. data/samples/scripts/lines_counter/lines_number.rb +32 -0
  184. data/samples/scripts/lines_counter/readme +5 -0
  185. data/samples/scripts/readme +1 -0
  186. metadata +197 -7
  187. data/lib/clone/cms.rb +0 -56
  188. data/lib/clone/ext.rb +0 -77
  189. data/sample/test.rb +0 -30
@@ -0,0 +1,375 @@
1
+ {<img src="https://secure.travis-ci.org/ggilder/commander.png?branch=master" alt="Build Status" />}[http://travis-ci.org/ggilder/commander]
2
+
3
+ = Commander
4
+
5
+ The complete solution for Ruby command-line executables.
6
+ Commander bridges the gap between other terminal related libraries
7
+ you know and love (OptionParser, HighLine), while providing many new
8
+ features, and an elegant API.
9
+
10
+ == Features
11
+
12
+ * Easier than baking cookies
13
+ * Parses options using OptionParser
14
+ * Auto-populates struct with options ( no more { |v| options[:recursive] = v } )
15
+ * Auto-generates help documentation via pluggable help formatters
16
+ * Optional default command when none is present
17
+ * Global / Command level options
18
+ * Packaged with two help formatters (Terminal, TerminalCompact)
19
+ * Imports the highline gem for interacting with the terminal
20
+ * Adds additional user interaction functionality
21
+ * Highly customizable progress bar with intuitive, simple usage
22
+ * Multi-word command name support such as 'drupal module install MOD', rather than 'drupal module_install MOD'
23
+ * Sexy paging for long bodies of text
24
+ * Support for MacOS text-to-speech
25
+ * Command aliasing (very powerful, as both switches and arguments can be used)
26
+ * Growl notification support for MacOS
27
+ * Use the 'commander' executable to initialize a commander driven program
28
+
29
+ == Installation
30
+
31
+ $ gem install commander
32
+
33
+ == Quick Start
34
+
35
+ To generate a quick template for a commander app, run:
36
+
37
+ $ commander init yourfile.rb
38
+
39
+ == Example
40
+
41
+ For more option examples view the Commander::Command#option method. Also
42
+ an important feature to note is that action may be a class to instantiate,
43
+ as well as an object, specifying a method to call, so view the RDoc for more information.
44
+
45
+ require 'rubygems'
46
+ require 'commander/import'
47
+
48
+ # :name is optional, otherwise uses the basename of this executable
49
+ program :name, 'Foo Bar'
50
+ program :version, '1.0.0'
51
+ program :description, 'Stupid command that prints foo or bar.'
52
+
53
+ command :foo do |c|
54
+ c.syntax = 'foobar foo'
55
+ c.description = 'Displays foo'
56
+ c.action do |args, options|
57
+ say 'foo'
58
+ end
59
+ end
60
+
61
+ command :bar do |c|
62
+ c.syntax = 'foobar bar [options]'
63
+ c.description = 'Display bar with optional prefix and suffix'
64
+ c.option '--prefix STRING', String, 'Adds a prefix to bar'
65
+ c.option '--suffix STRING', String, 'Adds a suffix to bar'
66
+ c.action do |args, options|
67
+ options.default :prefix => '(', :suffix => ')'
68
+ say "#{options.prefix}bar#{options.suffix}"
69
+ end
70
+ end
71
+
72
+ $ foobar bar
73
+ # => (bar)
74
+
75
+ $ foobar bar --suffix '{' --prefix '}'
76
+ # => {bar}
77
+
78
+ == HighLine
79
+
80
+ As mentioned above the highline gem is imported into 'global scope', below
81
+ are some quick examples for how to utilize highline in your command(s):
82
+
83
+ # Ask for password masked with '*' character
84
+ ask("Password: ") { |q| q.echo = "*" }
85
+
86
+ # Ask for password
87
+ ask("Password: ") { |q| q.echo = false }
88
+
89
+ # Ask if the user agrees (yes or no)
90
+ agree("Do something?")
91
+
92
+ # Asks on a single line (note the space after ':')
93
+ ask("Name: ")
94
+
95
+ # Asks with new line after "Description:"
96
+ ask("Description:")
97
+
98
+ # Calls Date#parse to parse the date string passed
99
+ ask("Birthday? ", Date)
100
+
101
+ # Ensures Integer is within the range specified
102
+ ask("Age? ", Integer) { |q| q.in = 0..105 }
103
+
104
+ # Asks for a list of strings, converts to array
105
+ ask("Fav colors?", Array)
106
+
107
+ == HighLine & Interaction Additions
108
+
109
+ In addition to highline's fantastic choice of methods, commander adds the
110
+ following methods to simplify common tasks:
111
+
112
+ # Ask for password
113
+ password
114
+
115
+ # Ask for password with specific message and mask character
116
+ password "Enter your password please:", '-'
117
+
118
+ # Ask for CLASS, which may be any valid class responding to #parse. Date, Time, Array, etc
119
+ names = ask_for_array 'Names: '
120
+ bday = ask_for_date 'Birthday?: '
121
+
122
+ # Simple progress bar (Commander::UI::ProgressBar)
123
+ uris = %w[
124
+ http://vision-media.ca
125
+ http://google.com
126
+ http://yahoo.com
127
+ ]
128
+ progress uris do |uri|
129
+ res = open uri
130
+ # Do something with response
131
+ end
132
+
133
+ # 'Log' action to stdout
134
+ log "create", "path/to/file.rb"
135
+
136
+ # Enable paging of output after this point
137
+ enable_paging
138
+
139
+ # Ask editor for input (EDITOR environment variable or whichever is available: TextMate, vim, vi, emacs, nano, pico)
140
+ ask_editor
141
+
142
+ # Ask editor, supplying initial text
143
+ ask_editor 'previous data to update'
144
+
145
+ # Ask editor, preferring a specific editor
146
+ ask_editor 'previous data', 'vim'
147
+
148
+ # Choose from an array of elements
149
+ choice = choose("Favorite language?", :ruby, :perl, :js)
150
+
151
+ # Alter IO for the duration of the block
152
+ io new_input, new_output do
153
+ new_input_contents = $stdin.read
154
+ puts new_input_contents # outputs to new_output stream
155
+ end
156
+ # $stdin / $stdout reset back to original streams
157
+
158
+ # Speech synthesis
159
+ speak 'What is your favorite food? '
160
+ food = ask 'favorite food?: '
161
+ speak "Wow, I like #{food} too. We have so much in common."
162
+
163
+ # Execute arbitrary applescript
164
+ applescript 'foo'
165
+
166
+ # Converse with speech recognition server
167
+ case converse 'What is the best food?', :cookies => 'Cookies', :unknown => 'Nothing'
168
+ when :cookies
169
+ speak 'o.m.g. you are awesome!'
170
+ else
171
+ case converse 'That is lame, shall I convince you cookies are the best?', :yes => 'Ok', :no => 'No', :maybe => 'Maybe another time'
172
+ when :yes
173
+ speak 'Well you see, cookies are just fantastic, they melt in your mouth.'
174
+ else
175
+ speak 'Ok then, bye.'
176
+ end
177
+ end
178
+
179
+ == Growl Notifications
180
+
181
+ Commander provides methods for displaying Growl notifications. To use these
182
+ methods you need to install http://github.com/visionmedia/growl which utilizes
183
+ the growlnotify[http://growl.info/extras.php#growlnotify] executable. Note that
184
+ growl is auto-imported by Commander when available, no need to require.
185
+
186
+ # Display a generic Growl notification
187
+ notify 'Something happened'
188
+
189
+ # Display an 'info' status notification
190
+ notify_info 'You have #{emails.length} new email(s)'
191
+
192
+ # Display an 'ok' status notification
193
+ notify_ok 'Gems updated'
194
+
195
+ # Display a 'warning' status notification
196
+ notify_warning '1 gem failed installation'
197
+
198
+ # Display an 'error' status notification
199
+ notify_error "Gem #{name} failed"
200
+
201
+ growlnotify can also be installed via homebrew[http://mxcl.github.com/homebrew/]:
202
+
203
+ $ brew install growlnotify
204
+
205
+ == Commander Goodies
206
+
207
+ === Option Defaults
208
+
209
+ The options struct passed to #action provides a #default method, allowing you
210
+ to set defaults in a clean manner for options which have not been set.
211
+
212
+ command :foo do |c|
213
+ c.option '--interval SECONDS', Integer, 'Interval in seconds'
214
+ c.option '--timeout SECONDS', Integer, 'Timeout in seconds'
215
+ c.action do |args, options|
216
+ options.default \
217
+ :interval => 2,
218
+ :timeout => 60
219
+ end
220
+ end
221
+
222
+ === Command Aliasing
223
+
224
+ Aliases can be created using the #alias_command method like below:
225
+
226
+ command :'install gem' do |c|
227
+ c.action { puts 'foo' }
228
+ end
229
+ alias_command :'gem install', :'install gem'
230
+
231
+ Or more complicated aliases can be made, passing any arguments
232
+ as if it was invoked via the command line:
233
+
234
+ command :'install gem' do |c|
235
+ c.syntax = 'install gem <name> [options]'
236
+ c.option '--dest DIR', String, 'Destination directory'
237
+ c.action { |args, options| puts "installing #{args.first} to #{options.dest}" }
238
+ end
239
+ alias_command :update, :'install gem', 'rubygems', '--dest', 'some_path'
240
+
241
+ $ foo update
242
+ # => installing rubygems to some_path
243
+
244
+ === Command Defaults
245
+
246
+ Although working with a command executable framework provides many
247
+ benefits over a single command implementation, sometimes you still
248
+ want the ability to create a terse syntax for your command. With that
249
+ in mind we may use #default_command to help with this. Considering
250
+ our previous :'install gem' example:
251
+
252
+ default_command :update
253
+
254
+ $ foo
255
+ # => installing rubygems to some_path
256
+
257
+ Keeping in mind that commander searches for the longest possible match
258
+ when considering a command, so if you were to pass arguments to foo
259
+ like below, expecting them to be passed to :update, this would be incorrect,
260
+ and would end up calling :'install gem', so be careful that the users do
261
+ not need to use command names within the arguments.
262
+
263
+ $ foo install gem
264
+ # => installing to
265
+
266
+ === Additional Global Help
267
+
268
+ Arbitrary help can be added using the following #program symbol:
269
+
270
+ program :help, 'Author', 'TJ Holowaychuk <tj@vision-media.ca>'
271
+
272
+ Which will output the rest of the help doc, along with:
273
+
274
+ AUTHOR:
275
+
276
+ TJ Holowaychuk <tj@vision-media.ca>
277
+
278
+ === Global Options
279
+
280
+ Although most switches will be at the command level, several are available
281
+ by default at the global level, such as --version, and --help. Using #global_option
282
+ you can add additional global options:
283
+
284
+ global_option('-c', '--config FILE', 'Load config data for your commands to use') { |file| ... }
285
+
286
+ This method accepts the same syntax as Commander::Command#option so check it out for documentation.
287
+
288
+ All global options regardless of providing a block are accessable at the command level. This
289
+ means that instead of the following:
290
+
291
+ global_option('--verbose') { $verbose = true }
292
+ ...
293
+ c.action do |args, options|
294
+ say 'foo' if $verbose
295
+ ...
296
+
297
+ You may:
298
+
299
+ global_option '--verbose'
300
+ ...
301
+ c.action do |args, options|
302
+ say 'foo' if options.verbose
303
+ ...
304
+
305
+ === Formatters
306
+
307
+ Two core formatters are currently available, the default Terminal formatter as well
308
+ as TerminalCompact. To utilize a different formatter simply use :help_formatter like below:
309
+
310
+ program :help_formatter, Commander::HelpFormatter::TerminalCompact
311
+
312
+ Or utilize the help formatter aliases:
313
+
314
+ program :help_formatter, :compact
315
+
316
+ This abstraction could be utilized to generate HTML documentation for your executable.
317
+
318
+ == Tips
319
+
320
+ When adding a global or command option, OptionParser implicitly adds a small
321
+ switch even when not explicitly created, for example -c will be the same as --config
322
+ in both examples, however '-c' will only appear in the documentation when explicitly
323
+ assigning it.
324
+
325
+ global_option '-c', '--config FILE'
326
+ global_option '--config FILE'
327
+
328
+ == ASCII Tables
329
+
330
+ For feature rich ASCII tables for your terminal app check out visionmedia's terminal-table gem at
331
+ http://github.com/visionmedia/terminal-table
332
+
333
+ +----------+-------+----+--------+-----------------------+
334
+ | Terminal | Table | Is | Wicked | Awesome |
335
+ +----------+-------+----+--------+-----------------------+
336
+ | | | | | get it while its hot! |
337
+ +----------+-------+----+--------+-----------------------+
338
+
339
+ == Running Specifications
340
+
341
+ $ rake spec
342
+
343
+ OR
344
+
345
+ $ spec --color spec
346
+
347
+ == Contrib
348
+
349
+ Feel free to fork and request a pull, or submit a ticket
350
+ http://github.com/visionmedia/commander/issues
351
+
352
+ == License
353
+
354
+ (The MIT License)
355
+
356
+ Copyright (c) 2008-2009 TJ Holowaychuk <tj@vision-media.ca>
357
+
358
+ Permission is hereby granted, free of charge, to any person obtaining
359
+ a copy of this software and associated documentation files (the
360
+ 'Software'), to deal in the Software without restriction, including
361
+ without limitation the rights to use, copy, modify, merge, publish,
362
+ distribute, sublicense, and/or sell copies of the Software, and to
363
+ permit persons to whom the Software is furnished to do so, subject to
364
+ the following conditions:
365
+
366
+ The above copyright notice and this permission notice shall be
367
+ included in all copies or substantial portions of the Software.
368
+
369
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
370
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
371
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
372
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
373
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
374
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
375
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,10 @@
1
+ require "rspec/core/rake_task"
2
+ require "bundler/gem_tasks"
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new do |t|
6
+ t.verbose = false
7
+ t.rspec_opts = '--color'
8
+ end
9
+
10
+ task :default => :spec
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'commander/import'
5
+
6
+ program :name, 'commander'
7
+ program :version, Commander::VERSION
8
+ program :description, 'Commander utility program.'
9
+
10
+ command :init do |c|
11
+ c.syntax = 'commander init <file>'
12
+ c.summary = 'Initialize a commander template'
13
+ c.description = 'Initialize an empty <file> with a commander template,
14
+ allowing very quick creation of commander executables.'
15
+ c.example 'Create a new file with a commander template.', 'commander init bin/my_executable'
16
+ c.action do |args, options|
17
+ file = args.shift || abort('file argument required.')
18
+ name = ask 'Machine name of program: '
19
+ description = ask 'Describe your program: '
20
+ commands = ask_for_array 'List the commands you wish to create: '
21
+ begin
22
+ File.open(file, 'w') do |f|
23
+ f.write <<-"...".gsub!(/^ {10}/, '')
24
+ #!/usr/bin/env ruby
25
+
26
+ require 'rubygems'
27
+ require 'commander/import'
28
+
29
+ program :version, '0.0.1'
30
+ program :description, '#{description}'
31
+
32
+ ...
33
+ commands.each do |command|
34
+ f.write <<-"...".gsub!(/^ {12}/, '')
35
+ command :#{command} do |c|
36
+ c.syntax = '#{name} #{command} [options]'
37
+ c.summary = ''
38
+ c.description = ''
39
+ c.example 'description', 'command example'
40
+ c.option '--some-switch', 'Some switch that does something'
41
+ c.action do |args, options|
42
+ # Do something or c.when_called #{name.capitalize}::Commands::#{command.capitalize}
43
+ end
44
+ end
45
+
46
+ ...
47
+ end
48
+ end
49
+ File.chmod 0755, file
50
+ say "Initialized template in #{file}"
51
+ rescue Exception => e
52
+ abort e
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "commander/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "commander"
7
+ s.version = Commander::VERSION
8
+ s.authors = ["TJ Holowaychuk", "Gabriel Gilder"]
9
+ s.email = ["ggilder@tractionco.com"]
10
+ s.homepage = "http://visionmedia.github.com/commander"
11
+ s.summary = "The complete solution for Ruby command-line executables"
12
+ s.description = "The complete solution for Ruby command-line executables. Commander bridges the gap between other terminal related libraries you know and love (OptionParser, HighLine), while providing many new features, and an elegant API."
13
+
14
+ s.rubyforge_project = "commander"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency("highline", "~> 1.6.11")
22
+
23
+ s.add_development_dependency("rspec", "~> 2")
24
+ s.add_development_dependency("rake")
25
+ s.add_development_dependency("simplecov")
26
+ end