From 02c692150bb8c2f46426c3958db30045aa667faf Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 31 Dec 2023 01:17:42 -0800 Subject: [PATCH 1/3] gracefully handle nil input in argparse.stringList --- library/lua/argparse.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/lua/argparse.lua b/library/lua/argparse.lua index 0a652f428..79c257a9d 100644 --- a/library/lua/argparse.lua +++ b/library/lua/argparse.lua @@ -130,7 +130,7 @@ end function stringList(arg, arg_name, list_length) if not list_length then list_length = 0 end - local list = arg:split(',') + local list = arg and (arg):split(',') or {} if list_length > 0 and #list ~= list_length then arg_error(arg_name, 'expected %d elements; found %d', list_length, #list) From 3c54ba7c09aa95fae1adc1ddce96bf2bddd523aa Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 31 Dec 2023 01:17:54 -0800 Subject: [PATCH 2/3] error out on missing burrow specification --- plugins/lua/autochop.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/lua/autochop.lua b/plugins/lua/autochop.lua index 239db9ec8..a1a736882 100644 --- a/plugins/lua/autochop.lua +++ b/plugins/lua/autochop.lua @@ -32,7 +32,11 @@ function setTargets(max, min) end local function do_set_burrow_config(var_name, val, burrows) - for _,bspec in ipairs(argparse.stringList(burrows)) do + burrows = argparse.stringList(burrows) + if #burrows == 0 then + qerror('no target burrows specified') + end + for _,bspec in ipairs(burrows) do local config = autochop_getBurrowConfig(bspec) config[var_name] = val autochop_setBurrowConfig(config.id, config.chop, config.clearcut, From 648dc20912d2030d4f6031c414d64aef95b046ad Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 31 Dec 2023 01:19:22 -0800 Subject: [PATCH 3/3] update changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 0670232a5..ee6f86794 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -60,6 +60,7 @@ Template for new versions: - `sort`: fix potential crash when removing jobs directly from the Tasks info screen ## Misc Improvements +- `autochop`: better error output when target burrows are not specified on the commandline - wherever units are listed in DFHack tools, properties like "agitated" or (-trained-) are now shown ## Documentation