drydock 0.6.3 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES.txt +20 -0
- data/README.rdoc +4 -4
- data/bin/example +2 -2
- data/drydock.gemspec +12 -11
- data/lib/drydock.rb +46 -13
- data/lib/drydock/mixins.rb +4 -0
- data/lib/{mixins → drydock/mixins}/object.rb +0 -0
- data/lib/{mixins → drydock/mixins}/string.rb +1 -1
- metadata +5 -4
data/CHANGES.txt
CHANGED
@@ -5,6 +5,26 @@ DRYDOCK, CHANGES
|
|
5
5
|
* Support putting descriptions into resource file (or __END__)
|
6
6
|
|
7
7
|
|
8
|
+
#### 0.6.5 (2009-05-21) #############################
|
9
|
+
|
10
|
+
* ADDED: "with_args" support for default command. When specified,
|
11
|
+
arguments can be passed to the default command with run in the
|
12
|
+
short form. e.g. "script arg1 arg2" == "script cmdname arg1 arg2"
|
13
|
+
|
14
|
+
#### 0.6.3 (2009-05-10) #############################
|
15
|
+
|
16
|
+
* ADDED: show-commands now displays a note about which command is the default
|
17
|
+
* CHANGE: Moved mixins to lib/drydock/mixins (so other projects can require 'drydock/mixins')
|
18
|
+
* FIXED: Support for inline command aliases when specifying a class:
|
19
|
+
command [:name, :alias1, :alias2] => SomeClass
|
20
|
+
|
21
|
+
|
22
|
+
#### 0.6.2 (2009-05-07) #############################
|
23
|
+
|
24
|
+
* ADDED: drydock/console.rb to start a new wing in the drydock
|
25
|
+
* ADDED: mixins for String and Object (for Console)
|
26
|
+
|
27
|
+
|
8
28
|
#### 0.6.1 (2009-05-03) #############################
|
9
29
|
|
10
30
|
* FIXED: @@trawler raises an error in Ruby 1.8 if it's a Symbol
|
data/README.rdoc
CHANGED
@@ -31,7 +31,7 @@ See bin/example for more.
|
|
31
31
|
# variables defined here will be available to all commands.
|
32
32
|
end
|
33
33
|
|
34
|
-
|
34
|
+
about "A friendly welcome to the Drydock"
|
35
35
|
command :welcome do
|
36
36
|
puts "Welcome to Drydock."
|
37
37
|
puts "For available commands:"
|
@@ -39,7 +39,7 @@ See bin/example for more.
|
|
39
39
|
end
|
40
40
|
|
41
41
|
usage "USAGE: #{$0} laugh [-f]"
|
42
|
-
|
42
|
+
about "The captain commands his crew to laugh"
|
43
43
|
option :f, :faster, "A boolean value. Go even faster!"
|
44
44
|
command :laugh do |obj|
|
45
45
|
# +obj+ is an instance of Drydock::Command. The options you define are available
|
@@ -58,12 +58,12 @@ See bin/example for more.
|
|
58
58
|
def ahoy!; p "matey"; end
|
59
59
|
end
|
60
60
|
|
61
|
-
|
61
|
+
about "Do something with John West's Smoked Oysters"
|
62
62
|
command :oysters => JohnWestSmokedOysters do |obj|
|
63
63
|
p obj # => #<JohnWestSmokedOysters:0x42179c ... >
|
64
64
|
end
|
65
65
|
|
66
|
-
|
66
|
+
about "My way of saying hello!"
|
67
67
|
command :ahoy! => JohnWestSmokedOysters
|
68
68
|
# If you don't provide a block, Drydock will call JohnWestSmokedOysters#ahoy!
|
69
69
|
|
data/bin/example
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#!/usr/bin/
|
1
|
+
#!/usr/bin/ruby
|
2
2
|
|
3
3
|
# Seafaring Drydock Examples
|
4
4
|
#
|
@@ -102,7 +102,7 @@ module Example
|
|
102
102
|
end
|
103
103
|
|
104
104
|
about "My way of saying hello!"
|
105
|
-
command :ahoy! => JohnWestSmokedOysters
|
105
|
+
command [:ahoy!, :hello!] => JohnWestSmokedOysters
|
106
106
|
# If you don't provide a block, Drydock will call JohnWestSmokedOysters#ahoy!
|
107
107
|
|
108
108
|
|
data/drydock.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
@spec = Gem::Specification.new do |s|
|
2
2
|
s.name = %q{drydock}
|
3
|
-
s.version = "0.6.
|
3
|
+
s.version = "0.6.5"
|
4
4
|
s.specification_version = 1 if s.respond_to? :specification_version=
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
|
@@ -12,16 +12,17 @@
|
|
12
12
|
# = MANIFEST =
|
13
13
|
# git ls-files
|
14
14
|
s.files = %w(
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
15
|
+
CHANGES.txt
|
16
|
+
LICENSE.txt
|
17
|
+
README.rdoc
|
18
|
+
Rakefile
|
19
|
+
bin/example
|
20
|
+
drydock.gemspec
|
21
|
+
lib/drydock.rb
|
22
|
+
lib/drydock/console.rb
|
23
|
+
lib/drydock/mixins.rb
|
24
|
+
lib/drydock/mixins/object.rb
|
25
|
+
lib/drydock/mixins/string.rb
|
25
26
|
)
|
26
27
|
|
27
28
|
# s.add_dependency ''
|
data/lib/drydock.rb
CHANGED
@@ -3,8 +3,7 @@ require 'ostruct'
|
|
3
3
|
require 'stringio'
|
4
4
|
|
5
5
|
require 'drydock/console'
|
6
|
-
require 'mixins
|
7
|
-
require 'mixins/object'
|
6
|
+
require 'drydock/mixins'
|
8
7
|
|
9
8
|
module Drydock
|
10
9
|
class FancyArray < Array #:nodoc:
|
@@ -292,7 +291,8 @@ module Drydock
|
|
292
291
|
if @global.verbose > 0
|
293
292
|
puts # empty line
|
294
293
|
cmd_names_sorted.each do |cmd|
|
295
|
-
puts "
|
294
|
+
puts "$ %s" % [@executable] if Drydock.default?(cmd)
|
295
|
+
puts "$ %s %s" % [@executable, cmds[cmd][:pretty]]
|
296
296
|
puts "%10s: %s" % ["About", cmds[cmd][:desc]] if cmds[cmd][:desc]
|
297
297
|
if cmds[cmd][:aliases]
|
298
298
|
cmds[cmd][:aliases].sort!{ |a,b| a.size <=> b.size }
|
@@ -306,7 +306,8 @@ module Drydock
|
|
306
306
|
aliases = cmds[cmd][:aliases] || []
|
307
307
|
aliases.sort!{ |a,b| a.size <=> b.size }
|
308
308
|
aliases = aliases.empty? ? '' : "(aliases: #{aliases.join(', ')})"
|
309
|
-
|
309
|
+
pattern = Drydock.default?(cmd) ? "* %-16s %s" : " %-16s %s"
|
310
|
+
puts pattern % [cmds[cmd][:pretty], aliases]
|
310
311
|
end
|
311
312
|
end
|
312
313
|
end
|
@@ -370,6 +371,7 @@ module Drydock
|
|
370
371
|
@@command_actions = []
|
371
372
|
|
372
373
|
@@default_command = nil
|
374
|
+
@@default_command_with_args = false
|
373
375
|
|
374
376
|
@@commands = {}
|
375
377
|
@@command_descriptions = []
|
@@ -454,12 +456,31 @@ module Drydock
|
|
454
456
|
# # ...
|
455
457
|
# end
|
456
458
|
#
|
457
|
-
|
459
|
+
# If +with_args+ is specified, the default command will receive all unknown
|
460
|
+
# values as arguments. This is necessary to define explicitly because drydock
|
461
|
+
# parses arguments expecting a command name. If the default command accepts
|
462
|
+
# arguments and with_args is not specified, drydock will raise an unknown
|
463
|
+
# command exception for the first argument.
|
464
|
+
#
|
465
|
+
def default(cmd=nil, with_args=false, &b)
|
458
466
|
raise "Calling default requires a command name or a block" unless cmd || b
|
459
467
|
# Creates the command and returns the name or just stores given name
|
460
468
|
@@default_command = (b) ? command(cmd || :default, &b).cmd : canonize(cmd)
|
469
|
+
# IDEA: refactor out the argument parser to support different types of CLI
|
470
|
+
@@default_command_with_args = with_args ? true : false
|
471
|
+
@@default_command
|
472
|
+
end
|
473
|
+
|
474
|
+
# Is +cmd+ the default command?
|
475
|
+
def default?(cmd)
|
476
|
+
return false if @@default_command.nil?
|
477
|
+
(@@default_command == canonize(cmd))
|
461
478
|
end
|
462
479
|
|
480
|
+
#
|
481
|
+
def default_with_args?; @@default_command_with_args; end
|
482
|
+
|
483
|
+
|
463
484
|
# Define a block for processing STDIN before the command is called.
|
464
485
|
# The command block receives the return value of this block as obj.stdin:
|
465
486
|
#
|
@@ -588,11 +609,15 @@ module Drydock
|
|
588
609
|
cmd = cmds.shift # Should we accept aliases here?
|
589
610
|
|
590
611
|
if cmd.is_a? Hash
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
612
|
+
klass = cmd.values.first
|
613
|
+
names = cmd.keys.first
|
614
|
+
if names.is_a? Array
|
615
|
+
cmd, cmds = names.shift, [names].flatten.compact
|
616
|
+
else
|
617
|
+
cmd = names
|
618
|
+
end
|
619
|
+
raise "#{klass} is not a subclass of Drydock::Command" unless klass.ancestors.member?(Drydock::Command)
|
620
|
+
c = klass.new(cmd, &b) # A custom class was specified
|
596
621
|
else
|
597
622
|
c = Drydock::Command.new(cmd, &b)
|
598
623
|
end
|
@@ -833,13 +858,21 @@ module Drydock
|
|
833
858
|
global_options = command_options = {}
|
834
859
|
cmd = nil
|
835
860
|
|
861
|
+
argv_copy = argv.clone # See: @@default_command_with_args below
|
862
|
+
|
836
863
|
global_options = @@global_opts_parser.getopts(argv)
|
837
864
|
cmd_name = (argv.empty?) ? @@default_command : argv.shift
|
838
865
|
|
839
866
|
unless command?(cmd_name)
|
840
|
-
|
841
|
-
|
842
|
-
|
867
|
+
# If requested, send all unknown arguments to the default command
|
868
|
+
if @@default_command_with_args
|
869
|
+
cmd_name = @@default_command
|
870
|
+
argv = argv_copy
|
871
|
+
else
|
872
|
+
raise UnknownCommand.new(cmd_name) unless trawler?
|
873
|
+
raise UnknownCommand.new(@@trawler) unless command?(@@trawler)
|
874
|
+
command_alias(@@trawler, cmd_name)
|
875
|
+
end
|
843
876
|
end
|
844
877
|
|
845
878
|
cmd = get_command(cmd_name)
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: drydock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Delano Mandelbaum
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-05-
|
12
|
+
date: 2009-05-21 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -32,8 +32,9 @@ files:
|
|
32
32
|
- drydock.gemspec
|
33
33
|
- lib/drydock.rb
|
34
34
|
- lib/drydock/console.rb
|
35
|
-
- lib/mixins
|
36
|
-
- lib/mixins/
|
35
|
+
- lib/drydock/mixins.rb
|
36
|
+
- lib/drydock/mixins/object.rb
|
37
|
+
- lib/drydock/mixins/string.rb
|
37
38
|
has_rdoc: true
|
38
39
|
homepage: http://github.com/delano/drydock
|
39
40
|
licenses: []
|