tool/lib/output.rb: Add --create-only
and --overwrite
options
This commit is contained in:
parent
f1c6da65f4
commit
de4a1ca792
@ -6,6 +6,7 @@ class Output
|
|||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@path = @timestamp = @ifchange = @color = nil
|
@path = @timestamp = @ifchange = @color = nil
|
||||||
|
@overwrite = @create_only = false
|
||||||
@vpath = VPath.new
|
@vpath = VPath.new
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -15,10 +16,12 @@ class Output
|
|||||||
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}
|
||||||
opt.on('--[no-]color') {|v| @color = v}
|
opt.on('--[no-]color') {|v| @color = v}
|
||||||
|
opt.on('--[no-]create-only') {|v| @create_only = v}
|
||||||
|
opt.on('--[no-]overwrite') {|v| @overwrite = v}
|
||||||
@vpath.def_options(opt)
|
@vpath.def_options(opt)
|
||||||
end
|
end
|
||||||
|
|
||||||
def write(data, overwrite: false, create_only: false)
|
def write(data, overwrite: @overwrite, create_only: @create_only)
|
||||||
unless @path
|
unless @path
|
||||||
$stdout.print data
|
$stdout.print data
|
||||||
return true
|
return true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user