Skip to content

Commit

Permalink
tool/lib/output.rb: Add --create-only and --overwrite options
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Aug 23, 2023
1 parent f1c6da6 commit de4a1ca
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tool/lib/output.rb
Expand Up @@ -6,6 +6,7 @@ class Output

def initialize
@path = @timestamp = @ifchange = @color = nil
@overwrite = @create_only = false
@vpath = VPath.new
end

Expand All @@ -15,10 +16,12 @@ def def_options(opt)
opt.on('-t', '--timestamp[=PATH]') {|v| @timestamp = v || true}
opt.on('-c', '--[no-]if-change') {|v| @ifchange = 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)
end

def write(data, overwrite: false, create_only: false)
def write(data, overwrite: @overwrite, create_only: @create_only)
unless @path
$stdout.print data
return true
Expand Down

0 comments on commit de4a1ca

Please sign in to comment.