file2lastrev.rb: use output.rb for the options

This commit is contained in:
Nobuyoshi Nakada 2022-11-01 12:29:46 +09:00
parent 7e6e94262c
commit 6bf458eefd
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6

View File

@ -8,6 +8,7 @@ require 'optparse'
# this file run with BASERUBY, which may be older than 1.9, so no # this file run with BASERUBY, which may be older than 1.9, so no
# require_relative # require_relative
require File.expand_path('../lib/vcs', __FILE__) require File.expand_path('../lib/vcs', __FILE__)
require File.expand_path('../lib/output', __FILE__)
Program = $0 Program = $0
@ -20,6 +21,7 @@ def self.format=(format)
end end
@suppress_not_found = false @suppress_not_found = false
@limit = 20 @limit = 20
@output = Output.new
time_format = '%Y-%m-%dT%H:%M:%S%z' time_format = '%Y-%m-%dT%H:%M:%S%z'
vcs = nil vcs = nil
@ -51,6 +53,7 @@ OptionParser.new {|opts|
opts.on("-q", "--suppress_not_found") do opts.on("-q", "--suppress_not_found") do
@suppress_not_found = true @suppress_not_found = true
end end
@output.def_options(opts)
opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}" opts.order! rescue abort "#{File.basename(Program)}: #{$!}\n#{opts}"
begin begin
vcs = VCS.detect(srcdir || ".", vcs_options, opts.new) vcs = VCS.detect(srcdir || ".", vcs_options, opts.new)
@ -69,7 +72,7 @@ formatter =
} }
when :revision_h when :revision_h
Proc.new {|last, changed, modified, branch, title| Proc.new {|last, changed, modified, branch, title|
vcs.revision_header(last, modified, modified, branch, title, limit: @limit) vcs.revision_header(last, modified, modified, branch, title, limit: @limit).join("\n")
} }
when :doxygen when :doxygen
Proc.new {|last, changed| Proc.new {|last, changed|
@ -86,7 +89,7 @@ formatter =
ok = true ok = true
(ARGV.empty? ? [nil] : ARGV).each do |arg| (ARGV.empty? ? [nil] : ARGV).each do |arg|
begin begin
puts formatter[*vcs.get_revisions(arg)] @output.write(formatter[*vcs.get_revisions(arg)]+"\n")
rescue => e rescue => e
warn "#{File.basename(Program)}: #{e.message}" warn "#{File.basename(Program)}: #{e.message}"
ok = false ok = false