commandable 0.2.0.rc1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +63 -58
- data/bin/commandable +1 -1
- data/commandable.gemspec +20 -2
- data/lib/commandable/commandable.rb +10 -10
- data/lib/commandable/version.rb +1 -1
- data/spec/commandable/app_controller_spec.rb +1 -1
- data/spec/commandable/command_line_execution_spec.rb +1 -1
- data/spec/commandable/help_generator_spec.rb +6 -6
- data/spec/commandable/reset_spec.rb +2 -2
- metadata +32 -18
data/README.markdown
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
# Commandable
|
2
|
-
The easiest way to add command line control to your Ruby app.
|
2
|
+
The easiest way to add command line control to your Ruby app.
|
3
3
|
|
4
|
-
Stop wasting time writing
|
4
|
+
Stop wasting time writing WET (Write Everything Twice) command line interpreters, or repeatedly writing code for existing ones like optparser, then writing help/usage methods that you constantly have to update as your code changes. Now you can add a single line above an existing method and that method will be available from the command line.
|
5
|
+
|
6
|
+
Best of all the help/usage instructions are automatically generated using the method itself! When you change your methods the help instructions change automajically! There's no extra effort needed on your part.
|
5
7
|
|
6
8
|
The whole process can take as little as four lines of code:
|
7
9
|
|
@@ -14,6 +16,17 @@ Don't think of **Commandable** as a way to add command line switches to your app
|
|
14
16
|
|
15
17
|
You can now "use your words" to let people interact with your apps in a natural way.
|
16
18
|
|
19
|
+
## Testing for a Better Tomorrow ##
|
20
|
+
|
21
|
+
I have the gem set up to ask if you would like to test on install so please allow the tests to run and upload. This will allow me to find any problems on different platforms.
|
22
|
+
|
23
|
+
You can take a look at the test results yourself here:
|
24
|
+
|
25
|
+
<http://test.rubygems.org/gems/hashmodel/v/0.4.0>
|
26
|
+
|
27
|
+
Thanks for your help.
|
28
|
+
|
29
|
+
|
17
30
|
## Status
|
18
31
|
|
19
32
|
2011-03-21 - Release Cadidate: 0.2.0.rc1
|
@@ -172,23 +185,23 @@ One of the great features of **Commandable** is that it will automatically creat
|
|
172
185
|
|
173
186
|
A typical help output looks something like this:
|
174
187
|
|
175
|
-
|
176
|
-
|
177
|
-
|
188
|
+
Commandable - The easiest way to add command line control to your app.
|
189
|
+
Copyrighted free software - Copyright (c) 2011 Mike Bethany.
|
190
|
+
Version: 0.2.0
|
178
191
|
|
179
|
-
|
192
|
+
Usage: commandable <command> [parameters] [<command> [parameters]...]
|
180
193
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
194
|
+
Command Parameters Description
|
195
|
+
error : Will raise a programmer error, not a user error
|
196
|
+
so you see what happens when you have bad code
|
197
|
+
examples [path] : Copies the test classes to a folder so
|
198
|
+
you can see a bunch of small examples
|
199
|
+
readme : displays the readme file (default)
|
200
|
+
v : <xor> Application Version
|
201
|
+
version : <xor> Application Version
|
202
|
+
widget [path] : Copies a fully working app demonstrating how
|
203
|
+
to use Commandable with RSpec and Cucumber
|
204
|
+
help : you're looking at it now
|
192
205
|
|
193
206
|
|
194
207
|
|
@@ -203,20 +216,20 @@ If you would like to see a bunch of simple classes that demonstrate its uses run
|
|
203
216
|
|
204
217
|
### Commandable Options
|
205
218
|
|
206
|
-
|
219
|
+
These are the basic options you will want to be aware of. Specifically you really want to set `Commandable#app_exe` and `Commandable#app_info` so that the help/usage instructions are fully fleshed out.
|
207
220
|
|
208
|
-
**Commandable.app\
|
221
|
+
**Commandable.app\_exe**
|
209
222
|
_default = ""_
|
210
|
-
|
223
|
+
This is what a user would type to run your app; don't set it to "My App" set it to "myapp". When this is set the help instructions will include a usage line with your executables name.
|
211
224
|
|
212
225
|
**Commandable.app\_info**
|
213
226
|
_default = ""_
|
214
227
|
This is informational text that will print above the help/usage instructions.
|
215
228
|
|
216
229
|
**Commandable.verbose\_parameters**
|
217
|
-
_default =
|
218
|
-
If set to
|
219
|
-
**Important!** This should only be set once, before any files load. Changing the value after files are loaded will make no difference since parameters are only parsed when the source file loads.
|
230
|
+
_default = false_
|
231
|
+
If set to true help instructions will include the default values in the parameter list.
|
232
|
+
**Important!** This should only be set once, after you `require 'commandable'` but before any of your code files load. Changing the value after files are loaded will make no difference since parameters are only parsed when the source file loads.
|
220
233
|
|
221
234
|
Commandable.verbose_parameters = true
|
222
235
|
# Will print:
|
@@ -228,7 +241,7 @@ If set to false help instructions will not print out default values.
|
|
228
241
|
|
229
242
|
### Colorized Output Options
|
230
243
|
|
231
|
-
The help information can be colored using the standard ANSI escape commands found in the `term-ansicolor-hi` gem. The `term-ansicolor-hi` gem it installed as a dependency but just in case you can install it yourself by running:
|
244
|
+
The help information can be colored using the standard ANSI escape commands found in the `term-ansicolor-hi` gem. The `term-ansicolor-hi` gem it installed as a dependency but just in case you have problems you can install it yourself by running:
|
232
245
|
|
233
246
|
$ [sudo] gem install term-ansicolor-hi
|
234
247
|
|
@@ -239,7 +252,7 @@ Then you can do something like this:
|
|
239
252
|
c = Term::ANSIColorHI
|
240
253
|
|
241
254
|
Commandable.color_app_info = c.intense_white + c.bold
|
242
|
-
Commandable.
|
255
|
+
Commandable.color_app_exe = c.intense_green + c.bold
|
243
256
|
Commandable.color_command = c.intense_yellow
|
244
257
|
Commandable.color_description = c.intense_white
|
245
258
|
Commandable.color_parameter = c.intense_cyan
|
@@ -253,7 +266,7 @@ Then you can do something like this:
|
|
253
266
|
|
254
267
|
**Commandable.color\_output**
|
255
268
|
_default = true_
|
256
|
-
Set to false to disable colorized help/usage instructions. You might find
|
269
|
+
Set to false to disable colorized help/usage instructions. You might find the colors really, really annoying...
|
257
270
|
|
258
271
|
**Commandable.color\_app\_info**
|
259
272
|
_default = intense\_white_ + bold
|
@@ -261,7 +274,7 @@ The color the app_info text will be in the help message
|
|
261
274
|
|
262
275
|
**Commandable.color\_app\_name**
|
263
276
|
_default = intense\_green_ + bold
|
264
|
-
The color the
|
277
|
+
The color the app_exe will be in the usage line in the help message
|
265
278
|
|
266
279
|
**Commandable.color\_command**
|
267
280
|
_default = intense\_yellow_
|
@@ -292,6 +305,9 @@ _default = intense\_black_ + bold
|
|
292
305
|
The color the error description will be in error messages
|
293
306
|
|
294
307
|
|
308
|
+
The best way to see what all this means it just type `commandable help` and you'll see the help instructions in color.
|
309
|
+
|
310
|
+
|
295
311
|
### Executing the Command Line
|
296
312
|
|
297
313
|
There are two ways of using **Commandable** to run your methods. You can use its built in execute method to automatically run whatever is entered on the command line or you can have **Commandable** build an array of procs that you can execute yourself. This allows you to have finer grain control over the execution of the commands as you can deal with the return values as you run each command.
|
@@ -300,29 +316,18 @@ There are two ways of using **Commandable** to run your methods. You can use its
|
|
300
316
|
|
301
317
|
**Commandable#execution_queue(ARGV)**
|
302
318
|
|
303
|
-
|
319
|
+
After you've added a command method and a description above a method you can then get an array of command you should execute by sending the command line arguments (ARGV) to `Commandable#execution_queue`. That method will generate an array of procs to run based on the user's input. They're sorted by the order of priority you specified when creating the commands or if they all have the same priority they sort by how they were entered.
|
304
320
|
|
305
321
|
# execution_queue returns an array of hashes which
|
306
322
|
# in turn contains the method name keyed to :method
|
307
|
-
# and a proc
|
323
|
+
# and a proc keyed to, you guessed it, :proc
|
308
324
|
# It looks like this:
|
309
|
-
# [{:method => :method_name, :xor=>(:xor group or nil), :parameters=>[...], :priority, :proc => #<proc:>}, ...]
|
325
|
+
# [{:method => :method_name, :xor=>(:xor group or nil), :parameters=>[...], :priority=>0, :proc => #<proc:>}, ...]
|
310
326
|
#
|
311
327
|
# The array is automatically sorted by priority (higher numbers first, 10 > 0)
|
312
|
-
|
313
|
-
# First get the array of commands
|
314
|
-
command_queue = Commandable.execution_queue(ARGV) # no need to give it ARGV, it's there for testing
|
315
|
-
|
316
|
-
return_values = (command_queue.shift)[:proc].call
|
317
|
-
# do something with the return values
|
318
|
-
|
319
|
-
# check for more values however you want
|
320
|
-
more_return_values = command_queue.shift[:proc].call unless command_queue.empty?
|
321
|
-
|
322
|
-
If you need a little more control:
|
323
328
|
|
324
329
|
# First get the array of commands
|
325
|
-
command_queue = Commandable.execution_queue(ARGV) #
|
330
|
+
command_queue = Commandable.execution_queue(ARGV) # #ARGV will be cloned so it won't change it
|
326
331
|
|
327
332
|
# Loop through the array calling the commands and dealing with the results
|
328
333
|
command_queue.each do |cmd|
|
@@ -352,13 +357,11 @@ If you need a little more control:
|
|
352
357
|
|
353
358
|
**Commandable.execute(ARGV)**
|
354
359
|
|
355
|
-
The easiest way to use **Commandable** is to just let it do all the work. This works great if all you need to do is make your methods available from the command line. You can also design a controller class with **Commandable** in mind and run all you
|
360
|
+
The easiest way to use **Commandable** is to just let it do all the work. This works great if all you need to do is make your methods available from the command line. You can also design a controller class with **Commandable** in mind and run all you commands from there.
|
356
361
|
|
357
|
-
When you call the `Commandable#execute` method it will
|
362
|
+
When you call the `Commandable#execute` method it will print out the return values for each method called automatically. This method is really meant to be the super easy way to do things. No muss, no fuss. Fire and forget. Shooting fish in a barrel... etc.
|
358
363
|
|
359
|
-
|
360
|
-
|
361
|
-
Simply configure your bin file to run `Commandable#execute`:
|
364
|
+
You just need to configure your bin file with the app settings and then run `Commandable#execute`:
|
362
365
|
|
363
366
|
**[your Ruby app directory]/bin/your\_app\_name**
|
364
367
|
|
@@ -367,7 +370,7 @@ Simply configure your bin file to run `Commandable#execute`:
|
|
367
370
|
require 'commandable'
|
368
371
|
Commandable.verbose_parameters = false
|
369
372
|
Commandable.color_output = true
|
370
|
-
Commandable.
|
373
|
+
Commandable.app_exe = "myapp"
|
371
374
|
Commandable.app_info =
|
372
375
|
"""
|
373
376
|
My App - It does stuff and things!
|
@@ -378,36 +381,38 @@ Simply configure your bin file to run `Commandable#execute`:
|
|
378
381
|
# a configuration file to load the settings then your app
|
379
382
|
# See the Widget app for an example of this.
|
380
383
|
require 'yourappname'
|
381
|
-
|
382
|
-
|
384
|
+
Commandable.execute(ARGV)
|
385
|
+
|
383
386
|
|
387
|
+
I actually prefer to create a separate file for my **Commandable** configuration and load it in my main app file in the `lib` directory. Again, take a look at `Widget` to see what I mean.
|
384
388
|
|
385
|
-
|
389
|
+
You can get a copy of widget by running `commandable widget [path]` and it will copy the example app to the directory you specify.
|
386
390
|
|
387
391
|
## In closing... ##
|
388
392
|
|
389
|
-
One really cool thing about this design is you can extend another app and add your own command line controls without having to crack open their code. The other app doesn't even have to use **Commandable**. You can just write your own methods that call the methods of the original program.
|
393
|
+
One really cool thing about this design is you can dynamically extend another app and add your own command line controls without having to crack open their code. The other app doesn't even have to use **Commandable**. You can just write your own methods that call the methods of the original program.
|
390
394
|
|
391
395
|
I should also say the code is really, really ugly right now. Thats the very next thing I will be working on for this project. This is the "rough draft" version that works perfectly well but is very ugly code-wise. I needed to use it right now so am putting it out as is.
|
392
396
|
|
393
397
|
If you have any questions about how the code works I've tried to give as much info in these docs as possible but I am also an OCD level commenter so you should be able to find fairly good explanations of what I'm doing in the code.
|
394
398
|
|
395
|
-
Most of all it should be simple to use so if you have any problems please drop me a line. Also if you make any changes please send me a pull request. I when people
|
399
|
+
Most of all it should be simple to use so if you have any problems please drop me a line. Also if you make any changes please send me a pull request. I hate when people don't respond to them, even to deny them, so I'm pretty good about that sort of thing.
|
396
400
|
|
397
401
|
|
398
402
|
## To Do
|
399
403
|
|
400
|
-
|
404
|
+
All done... for now.
|
401
405
|
|
402
406
|
###Next version:
|
403
407
|
|
408
|
+
* Add a way to use or discover version numbers. Might have to force standardization and not allow configuration since it should be DRY.
|
404
409
|
* Needs a massive refactoring.
|
405
|
-
*
|
410
|
+
* Add a generator to automatically add Commandable support to your app.
|
406
411
|
* Reorganize docs to be more logical and less the result of my scribblings as I develop.
|
407
|
-
* Try to figure out how to trap `alias`
|
408
|
-
* Better formatting of help instructions, the existing one is fairly ugly.
|
412
|
+
* Try to figure out how to trap `alias` so I don't you don't have to use an additional `command`.
|
413
|
+
* Better formatting of help/usage instructions, the existing one is fairly ugly.
|
409
414
|
* Use comments below `command` as the description text so you don't have to repeat yourself to get RDoc to give you docs for your functions.
|
410
|
-
* Clean up RSpecs. I'm doing too many ugly tests
|
415
|
+
* Clean up RSpecs. I'm doing too many ugly tests instead of specifying behavior.
|
411
416
|
* Allow sorting of commands alphabetically or by priority
|
412
417
|
|
413
418
|
###Future versions:
|
data/bin/commandable
CHANGED
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + "/../lib")
|
|
3
3
|
require 'commandable'
|
4
4
|
Commandable.color_output = true
|
5
5
|
Commandable.verbose_parameters = false
|
6
|
-
Commandable.
|
6
|
+
Commandable.app_exe = "commandable"
|
7
7
|
Commandable.app_info =
|
8
8
|
"""
|
9
9
|
\e[92mCommandable\e[0m - The easiest way to add command line control to your app.
|
data/commandable.gemspec
CHANGED
@@ -11,8 +11,26 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.authors = ["Mike Bethany"]
|
12
12
|
s.email = ["mikbe.tk@gmail.com"]
|
13
13
|
s.homepage = "http://mikbe.tk"
|
14
|
-
s.summary = %q{The easiest way to add command line control to your
|
15
|
-
s.description =
|
14
|
+
s.summary = %q{The easiest way to add command line control to your Ruby apps.}
|
15
|
+
s.description = <<EOF
|
16
|
+
The easiest way to add command line control to your Ruby app.
|
17
|
+
|
18
|
+
Stop wasting time writing WET (Write Everything Twice) command line interpreters, or repeatedly writing code for existing ones like optparser, then writing help/usage methods that you constantly have to update as your code changes. Now you can add a single line above an existing method and that method will be available from the command line.
|
19
|
+
|
20
|
+
Best of all the help/usage instructions are automatically generated using the method itself! When you change your methods the help instructions change automajically! There's no extra effort needed on your part.
|
21
|
+
|
22
|
+
The whole process can take as little as four lines of code:
|
23
|
+
|
24
|
+
* You put a `command "I do something!"` line above your method.
|
25
|
+
* Add a `require 'commandable'` line somewhere (I'd put it in my bin).
|
26
|
+
* Then an `extend Commandable` inside your class.
|
27
|
+
* And finally a call to `Commandable.execute(ARGV)` in your bin file.
|
28
|
+
|
29
|
+
Don't think of Commandable as a way to add command line switches to your app but as a way to allow your app to be driven directly from the command line. No more confusing switches that mean one thing in one program and something completely different in another. (Can you believe some apps actually use `-v` for something other than "version" and `-h` for something other than "help?" Madness I say! Madness!)
|
30
|
+
|
31
|
+
You can now "use your words" to let people interact with your apps in a natural way.
|
32
|
+
EOF
|
33
|
+
|
16
34
|
s.license = 'MIT'
|
17
35
|
|
18
36
|
s.add_dependency("term-ansicolor-hi", "~>1.0.7")
|
@@ -20,8 +20,8 @@ module Commandable
|
|
20
20
|
# Describes your application, printed at the top of help/usage messages
|
21
21
|
attr_accessor :app_info
|
22
22
|
|
23
|
-
# Used when building the usage line, e.g. Usage:
|
24
|
-
attr_accessor :
|
23
|
+
# Used when building the usage line, e.g. Usage: app_exe [command] [parameters]
|
24
|
+
attr_accessor :app_exe
|
25
25
|
|
26
26
|
# If optional parameters show default values, true by default
|
27
27
|
attr_accessor :verbose_parameters
|
@@ -30,8 +30,8 @@ module Commandable
|
|
30
30
|
attr_accessor :color_output
|
31
31
|
# What color the app_info text will be in the help message
|
32
32
|
attr_accessor :color_app_info
|
33
|
-
# What color the
|
34
|
-
attr_accessor :
|
33
|
+
# What color the app_exe will be in the usage line in the help message
|
34
|
+
attr_accessor :color_app_exe
|
35
35
|
# What color the word "command" and the commands themselves will be in the help message
|
36
36
|
attr_accessor :color_command
|
37
37
|
# What color the description column header and text will be in the help message
|
@@ -65,7 +65,7 @@ module Commandable
|
|
65
65
|
clear_commands
|
66
66
|
reset_colors
|
67
67
|
@app_info = nil
|
68
|
-
@
|
68
|
+
@app_exe = nil
|
69
69
|
@verbose_parameters = true
|
70
70
|
@@default_method = nil
|
71
71
|
end
|
@@ -100,10 +100,10 @@ module Commandable
|
|
100
100
|
|
101
101
|
usage_text = " #{@c_usage}Usage:#{@c_reset} "
|
102
102
|
|
103
|
-
if Commandable.
|
103
|
+
if Commandable.app_exe
|
104
104
|
cmd_text = "<#{@c_command + @c_bold}command#{@c_reset}>"
|
105
105
|
parm_text = " [#{@c_parameter + @c_bold}parameters#{@c_reset}]" if max_parameter > 0
|
106
|
-
usage_text += "#{@
|
106
|
+
usage_text += "#{@c_app_exe + app_exe + @c_reset} #{cmd_text}#{parm_text} [#{cmd_text}#{parm_text}...]"
|
107
107
|
end
|
108
108
|
|
109
109
|
array = [usage_text, ""]
|
@@ -227,7 +227,7 @@ module Commandable
|
|
227
227
|
Term::ANSIColorHI.coloring = color_output
|
228
228
|
c = Term::ANSIColorHI
|
229
229
|
@color_app_info = c.intense_white + c.bold
|
230
|
-
@
|
230
|
+
@color_app_exe = c.intense_green + c.bold
|
231
231
|
@color_command = c.intense_yellow
|
232
232
|
@color_description = c.intense_white
|
233
233
|
@color_parameter = c.intense_cyan
|
@@ -253,7 +253,7 @@ module Commandable
|
|
253
253
|
def set_colors
|
254
254
|
if color_output
|
255
255
|
@c_app_info = @color_app_info
|
256
|
-
@
|
256
|
+
@c_app_exe = @color_app_exe
|
257
257
|
@c_command = @color_command
|
258
258
|
@c_description = @color_description
|
259
259
|
@c_parameter = @color_parameter
|
@@ -266,7 +266,7 @@ module Commandable
|
|
266
266
|
@c_bold = @color_bold
|
267
267
|
@c_reset = @color_reset
|
268
268
|
else
|
269
|
-
@c_app_info, @
|
269
|
+
@c_app_info, @c_app_exe, @c_command, @c_description,
|
270
270
|
@c_parameter, @c_usage, @c_bold, @c_reset, @c_error_word,
|
271
271
|
@c_error_name, @c_error_description = [""]*12
|
272
272
|
end
|
data/lib/commandable/version.rb
CHANGED
@@ -6,7 +6,7 @@ describe Commandable do
|
|
6
6
|
Commandable.reset_all
|
7
7
|
Commandable.color_output = true
|
8
8
|
Commandable.verbose_parameters = false
|
9
|
-
Commandable.
|
9
|
+
Commandable.app_exe = "commandable"
|
10
10
|
Commandable.app_info =
|
11
11
|
"""
|
12
12
|
\e[92mCommandable\e[0m - The easiest way to add command line control to your app.
|
@@ -51,13 +51,13 @@ describe Commandable do
|
|
51
51
|
it "adds the application name to the help output if it's given" do
|
52
52
|
Commandable.color_output = false
|
53
53
|
load 'parameter_class.rb'
|
54
|
-
Commandable.
|
54
|
+
Commandable.app_exe = "mycoolapp"
|
55
55
|
Commandable.help.to_s.should match(/Usage: mycoolapp <command>/)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "adds appliction information if given" do
|
59
59
|
load 'parameter_class.rb'
|
60
|
-
Commandable.
|
60
|
+
Commandable.app_exe = "mycoolapp"
|
61
61
|
app_info =
|
62
62
|
"""
|
63
63
|
My Cool App - It does stuff and things!
|
@@ -81,7 +81,7 @@ describe Commandable do
|
|
81
81
|
end
|
82
82
|
|
83
83
|
it "hides the doesn't show [parameters] in the usage instructions" do
|
84
|
-
Commandable.
|
84
|
+
Commandable.app_exe = "fakeapp"
|
85
85
|
execute_output_s([]).should_not match(/\[parameters\]/)
|
86
86
|
end
|
87
87
|
|
@@ -108,7 +108,7 @@ describe Commandable do
|
|
108
108
|
|
109
109
|
before(:each) do
|
110
110
|
load 'private_methods_bad.rb'
|
111
|
-
Commandable.
|
111
|
+
Commandable.app_exe = "mycoolapp"
|
112
112
|
Commandable.app_info =
|
113
113
|
""" My Cool App - It does stuff and things!
|
114
114
|
Copyright (c) 2011 Acme Inc."""
|
@@ -135,8 +135,8 @@ describe Commandable do
|
|
135
135
|
specify {lambda {Commandable.color_app_info = c.black}.should change{Commandable.help}}
|
136
136
|
end
|
137
137
|
|
138
|
-
context "when
|
139
|
-
specify {lambda {Commandable.
|
138
|
+
context "when app_exe is changed" do
|
139
|
+
specify {lambda {Commandable.color_app_exe = c.black}.should change{Commandable.help}}
|
140
140
|
end
|
141
141
|
|
142
142
|
context "when color_command is changed" do
|
@@ -5,7 +5,7 @@ describe Commandable do
|
|
5
5
|
before(:each) do
|
6
6
|
Commandable.reset_all
|
7
7
|
load 'parameter_class.rb'
|
8
|
-
Commandable.
|
8
|
+
Commandable.app_exe = "mycoolapp"
|
9
9
|
Commandable.app_info =
|
10
10
|
""" My Cool App - It does stuff and things!
|
11
11
|
Copyright (c) 2011 Acme Inc."""
|
@@ -13,7 +13,7 @@ describe Commandable do
|
|
13
13
|
|
14
14
|
context "when reseting all values" do
|
15
15
|
|
16
|
-
specify {lambda{Commandable.reset_all}.should change{Commandable.
|
16
|
+
specify {lambda{Commandable.reset_all}.should change{Commandable.app_exe}.from("mycoolapp").to(nil)}
|
17
17
|
specify {lambda{Commandable.reset_all}.should change{Commandable.app_info}.
|
18
18
|
from(%{ My Cool App - It does stuff and things!\n Copyright (c) 2011 Acme Inc.}).
|
19
19
|
to(nil)
|
metadata
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: commandable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mike Bethany
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-03-
|
12
|
+
date: 2011-03-23 00:00:00.000000000 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: term-ansicolor-hi
|
17
|
-
requirement: &
|
17
|
+
requirement: &2158240980 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 1.0.7
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2158240980
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rspec
|
28
|
-
requirement: &
|
28
|
+
requirement: &2158240520 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '2.5'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2158240520
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: cucumber
|
39
|
-
requirement: &
|
39
|
+
requirement: &2158240040 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0.10'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2158240040
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: aruba
|
50
|
-
requirement: &
|
50
|
+
requirement: &2158230600 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,11 +55,25 @@ dependencies:
|
|
55
55
|
version: '0.3'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
59
|
-
description: The easiest way to add command line control to your app.\
|
60
|
-
|
61
|
-
|
62
|
-
you.
|
58
|
+
version_requirements: *2158230600
|
59
|
+
description: ! "The easiest way to add command line control to your Ruby app.\n\nStop
|
60
|
+
wasting time writing WET (Write Everything Twice) command line interpreters, or
|
61
|
+
repeatedly writing code for existing ones like optparser, then writing help/usage
|
62
|
+
methods that you constantly have to update as your code changes. Now you can add
|
63
|
+
a single line above an existing method and that method will be available from the
|
64
|
+
command line.\n\nBest of all the help/usage instructions are automatically generated
|
65
|
+
using the method itself! When you change your methods the help instructions change
|
66
|
+
automajically! There's no extra effort needed on your part.\n\nThe whole process
|
67
|
+
can take as little as four lines of code: \n\n* You put a `command \"I do something!\"`
|
68
|
+
line above your method.\n* Add a `require 'commandable'` line somewhere (I'd put
|
69
|
+
it in my bin).\n* Then an `extend Commandable` inside your class.\n* And finally
|
70
|
+
a call to `Commandable.execute(ARGV)` in your bin file. \n\nDon't think of Commandable
|
71
|
+
as a way to add command line switches to your app but as a way to allow your app
|
72
|
+
to be driven directly from the command line. No more confusing switches that mean
|
73
|
+
one thing in one program and something completely different in another. (Can you
|
74
|
+
believe some apps actually use `-v` for something other than \"version\" and `-h`
|
75
|
+
for something other than \"help?\" Madness I say! Madness!)\n\nYou can now \"use
|
76
|
+
your words\" to let people interact with your apps in a natural way.\n"
|
63
77
|
email:
|
64
78
|
- mikbe.tk@gmail.com
|
65
79
|
executables:
|
@@ -134,15 +148,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
134
148
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
149
|
none: false
|
136
150
|
requirements:
|
137
|
-
- - ! '
|
151
|
+
- - ! '>='
|
138
152
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
153
|
+
version: '0'
|
140
154
|
requirements: []
|
141
155
|
rubyforge_project:
|
142
156
|
rubygems_version: 1.6.2
|
143
157
|
signing_key:
|
144
158
|
specification_version: 3
|
145
|
-
summary: The easiest way to add command line control to your
|
159
|
+
summary: The easiest way to add command line control to your Ruby apps.
|
146
160
|
test_files:
|
147
161
|
- autotest/discover.rb
|
148
162
|
- spec/commandable/app_controller_spec.rb
|