diff --git a/devel/rubygem-clamp/Makefile b/devel/rubygem-clamp/Makefile index 7d3c1c4c8423..54f8edc117da 100644 --- a/devel/rubygem-clamp/Makefile +++ b/devel/rubygem-clamp/Makefile @@ -1,19 +1,18 @@ # Created by: Michael Moll # $FreeBSD$ PORTNAME= clamp -PORTVERSION= 0.6.3 -PORTREVISION= 1 +PORTVERSION= 0.6.4 CATEGORIES= devel ruby MASTER_SITES= RG MAINTAINER= kvedulv@kvedulv.de COMMENT= Command-line utility framework for Ruby LICENSE= MIT USE_RUBY= yes USE_RUBYGEMS= yes RUBYGEM_AUTOPLIST= yes .include diff --git a/devel/rubygem-clamp/distinfo b/devel/rubygem-clamp/distinfo index a28e11a63d4b..7cc7e79584bf 100644 --- a/devel/rubygem-clamp/distinfo +++ b/devel/rubygem-clamp/distinfo @@ -1,2 +1,2 @@ -SHA256 (rubygem/clamp-0.6.3.gem) = 6e5feb738879f3ec8e74ac1d9a6339c316a65fdc054ef587851b0397ced1bab8 -SIZE (rubygem/clamp-0.6.3.gem) = 24064 +SHA256 (rubygem/clamp-0.6.4.gem) = e806278bee5df0aeaa7f15c55405a4d39ffe6182a1292c21462e1b771b60e138 +SIZE (rubygem/clamp-0.6.4.gem) = 24576 diff --git a/devel/rubygem-clamp/files/patch-i18n b/devel/rubygem-clamp/files/patch-i18n index 97b5d37d0203..2950a389bd20 100644 --- a/devel/rubygem-clamp/files/patch-i18n +++ b/devel/rubygem-clamp/files/patch-i18n @@ -1,191 +1,217 @@ -diff --git a/clamp-0.6.3.gemspec b/clamp-0.6.3.gemspec +diff --git a/clamp-0.6.4.gemspec b/clamp-0.6.4.gemspec index 8f51cc3..acab485 100644 ---- clamp-0.6.3.gemspec -+++ clamp-0.6.3.gemspec +--- clamp-0.6.4.gemspec ++++ clamp-0.6.4.gemspec @@ -43,6 +43,7 @@ - lib/clamp/command.rb - lib/clamp/errors.rb - lib/clamp/help.rb +- lib/clamp/messages.rb - lib/clamp/option/declaration.rb - lib/clamp/option/definition.rb - lib/clamp/option/parsing.rb diff --git a/lib/clamp/attribute/instance.rb b/lib/clamp/attribute/instance.rb index 8f51cc3..acab485 100644 --- lib/clamp/attribute/instance.rb +++ lib/clamp/attribute/instance.rb -@@ -72,7 +72,7 @@ def default_from_environment +@@ -69,7 +69,7 @@ def default_from_environment begin take(value) rescue ArgumentError => e - command.send(:signal_usage_error, "$#{attribute.environment_variable}: #{e.message}") + command.send(:signal_usage_error, Clamp.message(:env_argument_error, :env => attribute.environment_variable, :message => e.message)) end end diff --git a/lib/clamp/command.rb b/lib/clamp/command.rb index c6c50f4..52187ab 100644 --- lib/clamp/command.rb +++ lib/clamp/command.rb @@ -1,3 +1,4 @@ +require 'clamp/messages' require 'clamp/errors' require 'clamp/help' require 'clamp/option/declaration' @@ -91,7 +92,7 @@ def help def handle_remaining_arguments unless remaining_arguments.empty? - signal_usage_error "too many arguments" + signal_usage_error Clamp.message(:too_many_arguments) end end diff --git a/lib/clamp/help.rb b/lib/clamp/help.rb index e09731a..1e57530 100644 --- lib/clamp/help.rb +++ lib/clamp/help.rb -@@ -61,7 +61,7 @@ def string +@@ -1,4 +1,5 @@ + require 'stringio' ++require 'clamp/messages' + + module Clamp + +@@ -41,12 +42,12 @@ def help(invocation_path, builder = Builder.new) + help.add_usage(invocation_path, usage_descriptions) + help.add_description(description) + if has_parameters? +- help.add_list("Parameters", parameters) ++ help.add_list(Clamp.message(:parameters_heading), parameters) + end + if has_subcommands? +- help.add_list("Subcommands", recognised_subcommands) ++ help.add_list(Clamp.message(:subcommands_heading), recognised_subcommands) + end +- help.add_list("Options", recognised_options) ++ help.add_list(Clamp.message(:options_heading), recognised_options) + help.string + end + +@@ -61,7 +62,7 @@ def string end def add_usage(invocation_path, usage_descriptions) - puts "Usage:" + puts usage_heading usage_descriptions.each do |usage| puts " #{invocation_path} #{usage}".rstrip end -@@ -87,6 +87,12 @@ def add_list(heading, items) +@@ -87,6 +88,12 @@ def add_list(heading, items) end end + protected + + def usage_heading -+ "Usage:" ++ Clamp.message(:usage_heading) + ":" + end + private def puts(*args) diff --git a/lib/clamp/messages.rb b/lib/clamp/messages.rb new file mode 100644 index 0000000..61cce94 --- /dev/null +++ lib/clamp/messages.rb -@@ -0,0 +1,39 @@ +@@ -0,0 +1,43 @@ +module Clamp + + def self.messages=(messages) + @user_defined_messages = messages + end + + def self.message(key, options={}) + @user_defined_messages ||= {} + msg = @user_defined_messages[key] || messages[key] + format_string(msg, options) + end + + def self.messages + { + :too_many_arguments => "too many arguments", + :option_required => "option '%