From de4a1ca792996a682dc2fcf83093dd002a731a5e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 13 Aug 2023 00:38:45 +0900 Subject: tool/lib/output.rb: Add `--create-only` and `--overwrite` options --- tool/lib/output.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tool/lib') diff --git a/tool/lib/output.rb b/tool/lib/output.rb index 7db4e43881..25c6b47397 100644 --- a/tool/lib/output.rb +++ b/tool/lib/output.rb @@ -6,6 +6,7 @@ class Output def initialize @path = @timestamp = @ifchange = @color = nil + @overwrite = @create_only = false @vpath = VPath.new end @@ -15,10 +16,12 @@ class Output 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 -- cgit v1.2.3