From 498a4d09755baed82d37f25a2a72fed3b726bcf0 Mon Sep 17 00:00:00 2001 From: Ren Tatsumoto Date: Thu, 29 Feb 2024 02:24:23 +0300 Subject: [PATCH] print the arguments to be executed --- encoder.lua | 2 ++ helpers.lua | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/encoder.lua b/encoder.lua index 00941f9..6bae4f4 100644 --- a/encoder.lua +++ b/encoder.lua @@ -150,6 +150,8 @@ this.create_clip = function(clip_type, on_complete) end end)() + print("The following args will be executed:", table.concat(h.quote_if_necessary(args), " ") ) + local output_dir_path = utils.split_path(output_file_path) local location_info = utils.file_info(output_dir_path) if not location_info.is_dir then diff --git a/helpers.lua b/helpers.lua index 786ce37..8ccd137 100644 --- a/helpers.lua +++ b/helpers.lua @@ -83,4 +83,16 @@ this.human_readable_time = function(seconds) return ret end +this.quote_if_necessary = function(args) + local ret = {} + for _, v in ipairs(args) do + if v:find(" ") then + table.insert(ret, (v:find("'") and string.format('"%s"', v) or string.format("'%s'", v))) + else + table.insert(ret, v) + end + end + return ret +end + return this