file2lastrev.rb: separate options for Output
and VPath
So the `--srcdir` option in this file can override the same option in `VPath`.
This commit is contained in:
parent
60f12c7d2e
commit
ac06951c31
@ -28,11 +28,13 @@ vcs = nil
|
|||||||
OptionParser.new {|opts|
|
OptionParser.new {|opts|
|
||||||
opts.banner << " paths..."
|
opts.banner << " paths..."
|
||||||
vcs_options = VCS.define_options(opts)
|
vcs_options = VCS.define_options(opts)
|
||||||
|
opts.new {@output.def_options(opts)}
|
||||||
srcdir = nil
|
srcdir = nil
|
||||||
opts.new
|
opts.new
|
||||||
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
opts.on("--srcdir=PATH", "use PATH as source directory") do |path|
|
||||||
abort "#{File.basename(Program)}: srcdir is already set" if srcdir
|
abort "#{File.basename(Program)}: srcdir is already set" if srcdir
|
||||||
srcdir = path
|
srcdir = path
|
||||||
|
@output.vpath.add(srcdir)
|
||||||
end
|
end
|
||||||
opts.on("--changed", "changed rev") do
|
opts.on("--changed", "changed rev") do
|
||||||
self.format = :changed
|
self.format = :changed
|
||||||
@ -53,7 +55,6 @@ 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)
|
||||||
|
@ -10,6 +10,7 @@ class Output
|
|||||||
end
|
end
|
||||||
|
|
||||||
def def_options(opt)
|
def def_options(opt)
|
||||||
|
opt.separator(" Output common options:")
|
||||||
opt.on('-o', '--output=PATH') {|v| @path = v}
|
opt.on('-o', '--output=PATH') {|v| @path = v}
|
||||||
opt.on('-t', '--timestamp[=PATH]') {|v| @timestamp = v || true}
|
opt.on('-t', '--timestamp[=PATH]') {|v| @timestamp = v || true}
|
||||||
opt.on('-c', '--[no-]if-change') {|v| @ifchange = v}
|
opt.on('-c', '--[no-]if-change') {|v| @ifchange = v}
|
||||||
|
@ -53,6 +53,7 @@ class VPath
|
|||||||
end
|
end
|
||||||
|
|
||||||
def def_options(opt)
|
def def_options(opt)
|
||||||
|
opt.separator(" VPath common options:")
|
||||||
opt.on("-I", "--srcdir=DIR", "add a directory to search path") {|dir|
|
opt.on("-I", "--srcdir=DIR", "add a directory to search path") {|dir|
|
||||||
@additional << dir
|
@additional << dir
|
||||||
}
|
}
|
||||||
@ -80,6 +81,10 @@ class VPath
|
|||||||
@list
|
@list
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def add(path)
|
||||||
|
@additional << path
|
||||||
|
end
|
||||||
|
|
||||||
def strip(path)
|
def strip(path)
|
||||||
prefix = list.map {|dir| Regexp.quote(dir)}
|
prefix = list.map {|dir| Regexp.quote(dir)}
|
||||||
path.sub(/\A#{prefix.join('|')}(?:\/|\z)/, '')
|
path.sub(/\A#{prefix.join('|')}(?:\/|\z)/, '')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user