delano-drydock 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/CHANGES.txt +5 -0
  2. data/drydock.gemspec +2 -2
  3. data/lib/drydock.rb +19 -3
  4. metadata +2 -2
data/CHANGES.txt CHANGED
@@ -6,6 +6,11 @@ DRYDOCK, CHANGES
6
6
  * Inline commands aliases. command :cmd1, :cmd2 do; ...; end
7
7
 
8
8
 
9
+ #### 0.5.4 (2009-04-15) #############################
10
+
11
+ * ADDED: Better error handling with new Drydock::ArgError and Drydock::OptError
12
+
13
+
9
14
  #### 0.5.3 (2009-04-05) #############################
10
15
 
11
16
  * FIXED: Command actions were not being handled correctly. Added rdocs to
data/drydock.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  @spec = Gem::Specification.new do |s|
2
2
  s.name = %q{drydock}
3
- s.version = "0.5.3"
4
- s.date = %q{2009-04-05}
3
+ s.version = "0.5.4"
4
+ s.date = %q{2009-04-15}
5
5
  s.specification_version = 1 if s.respond_to? :specification_version=
6
6
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
7
7
 
data/lib/drydock.rb CHANGED
@@ -34,7 +34,21 @@ module Drydock
34
34
  end
35
35
  end
36
36
 
37
-
37
+ class ArgError < RuntimeError
38
+ attr_reader :arg, :cmd, :msg
39
+ def initialize(*args)
40
+ @msg = args.shift if args.size == 1
41
+ @arg, @cmd, @msg = *args
42
+ @cmd ||= 'COMMAND'
43
+ @msg = nil if @msg.empty?
44
+ end
45
+ def message; @msg || "Error: No #{@arg} provided"; end
46
+ def usage; "See: #{$0} #{@cmd} -h"; end
47
+ end
48
+ class OptError < ArgError
49
+ def message; @msg || "Error: No #{@arg} provided"; end
50
+ end
51
+
38
52
  # The base class for all command objects. There is an instance of this class
39
53
  # for every command defined. Global and command-specific options are added
40
54
  # as attributes to this class dynamically.
@@ -831,7 +845,7 @@ end
831
845
 
832
846
 
833
847
  trap ("SIGINT") do
834
- puts "#{$/}Exiting..."
848
+ puts "#{$/}Exiting... "
835
849
  exit 1
836
850
  end
837
851
 
@@ -845,8 +859,10 @@ at_exit {
845
859
  end
846
860
  Drydock.run!(ARGV, STDIN) if Drydock.run? && !Drydock.has_run?
847
861
  rescue => ex
848
- STDERR.puts "ERROR: #{ex.message}"
862
+ STDERR.puts "ERROR (#{ex.class.to_s}): #{ex.message}"
849
863
  STDERR.puts ex.backtrace if Drydock.debug?
864
+ rescue SystemExit
865
+ # Don't balk
850
866
  end
851
867
  }
852
868
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delano-drydock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
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-04-05 00:00:00 -07:00
12
+ date: 2009-04-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15