From 1b17af226a6669c61ab53020c1243ec682a3bc33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= Date: Tue, 9 Jun 2020 16:18:19 -0300 Subject: [PATCH 1/7] Implementar --info [SOMA-4624][SOMA-4906] --- sgad | 12 +++++++++++- sgad.sh | 7 ++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sgad b/sgad index b022bc0..48c7c3c 100755 --- a/sgad +++ b/sgad @@ -21,7 +21,7 @@ local function script_path() return str:match("(.*)/") or "." end -local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[3]) +local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[4]) if message then io.stderr:write(message.."\n") end @@ -38,6 +38,16 @@ if type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber( print("========================================") end +-- Show config info +if type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true })[tonumber(args[3])] then + local is_readonly = not next(config) and getmetatable(config) + local t = is_readonly and getmetatable(config).__index or config + print("============= DEBUG CONFIG =============") + print(util.debug_table(t)) + print("========================================") + os.exit(0) +end + if config.sga_name then io.stderr:write("\27[1;32m".."sgad starting '"..config.sga_name.."'...".."\27[0m\n") end diff --git a/sgad.sh b/sgad.sh index aa8c2a6..13f77ef 100755 --- a/sgad.sh +++ b/sgad.sh @@ -16,6 +16,7 @@ usage() { POSITIONAL="" # String para salvar argumentos passados ao comando debug=0 +info=0 while [ $# -gt 0 ] # Percorre todos argumentos do case "$1" in @@ -32,6 +33,10 @@ do debug=1 shift ;; + --info) + info=1 + shift + ;; --*) echo "$0: unrecognized option '$1'" usage @@ -56,4 +61,4 @@ if [ -z ${configfile} ]; then fi eval $(luarocks path --bin) -sgad ${configfile} ${debug} ${sga_name} 2>&1 | tee -a "${logfile}" +sgad ${configfile} ${debug} ${info} ${sga_name} 2>&1 | tee -a "${logfile}" -- GitLab From 0b139e45970cbe29375ea0374c70241f2e374c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= Date: Wed, 10 Jun 2020 11:09:21 -0300 Subject: [PATCH 2/7] =?UTF-8?q?Melhora=20c=C3=B3digo=20da=20implementa?= =?UTF-8?q?=C3=A7=C3=A3o=20de=20--info=20[SOMA-4778][SOMA-4906]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgad | 19 ++++++++----------- sgad.sh | 1 + 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/sgad b/sgad index 48c7c3c..1a52eb0 100755 --- a/sgad +++ b/sgad @@ -29,23 +29,20 @@ if not config then os.exit(1) end --- Show config debug -if type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber(args[2])] then - local is_readonly = not next(config) and getmetatable(config) - local t = is_readonly and getmetatable(config).__index or config - print("============= DEBUG CONFIG =============") - print(util.debug_table(t)) - print("========================================") -end --- Show config info -if type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true })[tonumber(args[3])] then +local debug = type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber(args[2])] +local info = type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true })[tonumber(args[3])] + +-- Show config debug +if debug or info then local is_readonly = not next(config) and getmetatable(config) local t = is_readonly and getmetatable(config).__index or config print("============= DEBUG CONFIG =============") print(util.debug_table(t)) print("========================================") - os.exit(0) + if info then + os.exit(0) + end end if config.sga_name then diff --git a/sgad.sh b/sgad.sh index 13f77ef..c4a90c6 100755 --- a/sgad.sh +++ b/sgad.sh @@ -12,6 +12,7 @@ usage() { echo "Available options are:" echo " --sga_name NAME SGA name to get config from a multiple config file" echo " --debug Enable debug information: show interpreted configuration." + echo " --info Shows debug information and exits" } POSITIONAL="" # String para salvar argumentos passados ao comando -- GitLab From 9b1fffc6bf5751bfccffc603f0c3395e662f95b8 Mon Sep 17 00:00:00 2001 From: Carla Ourofino Date: Wed, 10 Jun 2020 11:28:21 -0300 Subject: [PATCH 3/7] =?UTF-8?q?Atualiza=20coment=C3=A1rio=20e=20padroniza?= =?UTF-8?q?=20help.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SOMA-4624][SOMA-4906] --- sgad | 2 +- sgad.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sgad b/sgad index 1a52eb0..aae28b4 100755 --- a/sgad +++ b/sgad @@ -33,7 +33,7 @@ end local debug = type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber(args[2])] local info = type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true })[tonumber(args[3])] --- Show config debug +-- Show config debug/info if debug or info then local is_readonly = not next(config) and getmetatable(config) local t = is_readonly and getmetatable(config).__index or config diff --git a/sgad.sh b/sgad.sh index c4a90c6..889b6fc 100755 --- a/sgad.sh +++ b/sgad.sh @@ -10,9 +10,9 @@ logfile="logs/sgad_${timestamp}.log" usage() { echo "usage: $0 [configfile] [options]" echo "Available options are:" - echo " --sga_name NAME SGA name to get config from a multiple config file" + echo " --sga_name NAME SGA name to get config from a multiple config file." echo " --debug Enable debug information: show interpreted configuration." - echo " --info Shows debug information and exits" + echo " --info Show debug information and exit." } POSITIONAL="" # String para salvar argumentos passados ao comando -- GitLab From 9b61b821318f32a2efb94117c67c9908a09f214c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= Date: Wed, 10 Jun 2020 11:57:17 -0300 Subject: [PATCH 4/7] Tratar uso de --debug e --info juntos / Removendo header e footer no --info [SOMA-4624][SOMA-4925][SOMA-4930] --- sgad | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/sgad b/sgad index aae28b4..2ed32ba 100755 --- a/sgad +++ b/sgad @@ -8,10 +8,6 @@ module = nil -- needed for luasocket setting a global variable if Lua 5.2 safer.globals({}, { module = true, loadstring = true, setfenv = true, getfenv = true }) -if os.getenv("HOME") then - io.stderr:write("\27]0;sgad\7") -- set terminal title - io.stderr:write("\27[1;32m".."sgad intializing...".."\27[0m\n") -end local configuration = require("sga.configuration") local application = require("sga.application") @@ -37,14 +33,28 @@ local info = type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true }) if debug or info then local is_readonly = not next(config) and getmetatable(config) local t = is_readonly and getmetatable(config).__index or config - print("============= DEBUG CONFIG =============") - print(util.debug_table(t)) - print("========================================") - if info then - os.exit(0) + if debug and info then + print("============= DEBUG CONFIG =============") + print(util.debug_table(t)) + print("========================================") + else + if debug then + print("============= DEBUG CONFIG =============") + print(util.debug_table(t)) + print("========================================") + end + if info then + print(util.debug_table(t)) + os.exit(0) + end end end +if os.getenv("HOME") then + io.stderr:write("\27]0;sgad\7") -- set terminal title + io.stderr:write("\27[1;32m".."sgad initializing...".."\27[0m\n") +end + if config.sga_name then io.stderr:write("\27[1;32m".."sgad starting '"..config.sga_name.."'...".."\27[0m\n") end -- GitLab From bddff14cfd81ee9e32addb694b0e582b300cfd2d Mon Sep 17 00:00:00 2001 From: Carla Ourofino Date: Wed, 10 Jun 2020 12:09:46 -0300 Subject: [PATCH 5/7] =?UTF-8?q?Revis=C3=A3o=20de=20c=C3=B3digo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [SOMA-4624][SOMA-4925][SOMA-4930] --- sgad | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sgad b/sgad index 2ed32ba..91306e8 100755 --- a/sgad +++ b/sgad @@ -33,20 +33,13 @@ local info = type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true }) if debug or info then local is_readonly = not next(config) and getmetatable(config) local t = is_readonly and getmetatable(config).__index or config - if debug and info then + if debug then print("============= DEBUG CONFIG =============") print(util.debug_table(t)) print("========================================") - else - if debug then - print("============= DEBUG CONFIG =============") - print(util.debug_table(t)) - print("========================================") - end - if info then - print(util.debug_table(t)) - os.exit(0) - end + else --info + print(util.debug_table(t)) + os.exit(0) end end -- GitLab From 06afaf63641f68dc6f60bd41b53ec944015fea59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= Date: Wed, 10 Jun 2020 12:36:48 -0300 Subject: [PATCH 6/7] =?UTF-8?q?Corre=C3=A7=C3=A3o:=20linha=20em=20branco?= =?UTF-8?q?=20quando=20o=20arquivo=20de=20configura=C3=A7=C3=A3o=20=C3=A9?= =?UTF-8?q?=20m=C3=BAltiplo=20[SOMA-4624][SOMA-4931]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgad | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sgad b/sgad index 91306e8..a5be2a8 100755 --- a/sgad +++ b/sgad @@ -18,14 +18,13 @@ local function script_path() end local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[4]) -if message then +if message ~= '' then io.stderr:write(message.."\n") end if not config then os.exit(1) end - local debug = type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber(args[2])] local info = type(args[3]) == "boolean" and args[3] or ({ [0]=false, [1]=true })[tonumber(args[3])] -- GitLab From cde1de5a58ac7159c36c21c5c2a35f5531596fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Manh=C3=A3es?= Date: Wed, 10 Jun 2020 14:29:07 -0300 Subject: [PATCH 7/7] =?UTF-8?q?Corre=C3=A7=C3=A3o:=20adicionando=20caso=20?= =?UTF-8?q?em=20que=20message=20=C3=A9=20nil=20[SOMA-4624][SOMA-4931]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sgad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sgad b/sgad index a5be2a8..cdb2aa2 100755 --- a/sgad +++ b/sgad @@ -18,7 +18,7 @@ local function script_path() end local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[4]) -if message ~= '' then +if message ~= '' and message ~= nil then io.stderr:write(message.."\n") end if not config then -- GitLab