https://svn.lrde.epita.fr/svn/lrdetools/trunk
Index: ChangeLog
from Nicolas Pouillard <ertai(a)lrde.epita.fr>
Some fixes.
* vcs/lib/vcs/vcs.rb:
Make the errors standards.
Switch now supports a comment attribute.
Clean up the failure hook.
Fix vcs --check.
vcs.rb | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
Index: vcs/lib/vcs/vcs.rb
--- vcs/lib/vcs/vcs.rb (revision 271)
+++ vcs/lib/vcs/vcs.rb (working copy)
@@ -100,7 +100,7 @@
def header ( progname, severity )
@@headers[[progname, severity]] ||= [
- '[', 'vcs', ']', ' ', progname, severity,
':', ' '
+ 'vcs', ': ', progname, severity, ':', ' '
].compact.map { |x| stylize x }.join
end
@@ -131,9 +131,8 @@
:warn => [:yellow],
:error => [:red],
:fatal => [:red, :blink],
- :'[' => [:blue],
- :']' => [:blue],
:':' => [:red],
+ :': ' => [:blue],
}
def stylize ( aString )
@@ -193,7 +192,7 @@
class Switch
cattr_reader :shortcuts
- attr_reader :name, :shortcuts, :argument
+ attr_reader :name, :shortcuts, :argument, :comment
@@re ||=
/^
@@ -209,12 +208,15 @@
(.*?) # An argument (--foo NUM)
\s*
(?:\{(.*)\})? # A type (--foo NUM {Integer})
+ \s*
+ (?:\(\(.*\)\))? # A comment (--foo ((Usage...)))
$/x
def initialize ( aString )
match = @@re.match(aString)
raise "Cannot parse switch: `#{aString}'" if match.nil?
- @name, @argument, @type = match[1], match[4], match[5]
+ @name = match[1]
+ @argument, @type, @comment = match[4..6]
@type = eval(@type) unless @type.nil?
@shortcuts = match[2..3].compact
end
@@ -279,7 +281,11 @@
result = []
options.each do |k, v|
raise if v == false
+ if k.to_s.size == 1
+ result << "-#{k}"
+ else
result << '--' + k.to_s.gsub('_', '-')
+ end
result << v.to_s if v != true
end
result
@@ -294,12 +300,14 @@
@h = HighLine.new
self.cmd_data_factory = VcsCmdDataFactory.new(:output => STDOUT, :error =>
STDERR)
- @runner.subscribe_hook(:failure) do |data|
+ @runner.subscribe_hook(:failure) do |command, data|
+ data = command if data.nil? # Backward compatiblity
+ msg = { 'command' => command.to_s.gsub(/"/, ''),
'data' => data }.to_yaml
if data.output == STDOUT
- logger.debug { raise data.to_yaml }
+ logger.debug { raise msg }
exit((data.status)? data.status.exitstatus : 1)
else
- raise data.to_yaml
+ raise msg
end
end
@runner.subscribe_hook(:display_command) do |cmd|
@@ -598,7 +606,7 @@
class << self
def add_conf_checker ( meth=nil, &block )
- @@checkers << (block.nil?)? meth : block
+ @@checkers << ((block.nil?)? meth : block)
end
def user_conf_match ( sym, file )