diff --git a/plugins/lua/blueprint.lua b/plugins/lua/blueprint.lua index 1682b9241..e9b7ec667 100644 --- a/plugins/lua/blueprint.lua +++ b/plugins/lua/blueprint.lua @@ -33,13 +33,15 @@ See the online DFHack documentation for more examples and details. function print_help() print(help_text) end -valid_phases = utils.invert{ +local valid_phase_list = { 'dig', 'build', 'place', 'query', } +valid_phases = utils.invert(valid_phase_list) + local function parse_cursor(opts, arg) local _, _, x, y, z = arg:find('^(%d+),(%d+),(%d+)$') if not x then @@ -73,10 +75,12 @@ local function parse_positionals(opts, args, start_argidx) local auto_phase = true local phase = args[argidx] while phase do - if valid_phases[phase] then - auto_phase = false - opts[phase] = true + if not valid_phases[phase] then + qerror(('unknown phase: "%s"; expected one of: %s'): + format(phase, table.concat(valid_phase_list, ', '))) end + auto_phase = false + opts[phase] = true argidx = argidx + 1 phase = args[argidx] end diff --git a/test/plugins/blueprint.lua b/test/plugins/blueprint.lua index d2a554847..e579a668f 100644 --- a/test/plugins/blueprint.lua +++ b/test/plugins/blueprint.lua @@ -49,8 +49,9 @@ function test.parse_gui_commandline() opts) opts = {} - b.parse_gui_commandline(opts, {'imaname', 'garbagephase'}) - expect.table_eq({auto_phase=true, name='imaname'}, opts) + expect.error_match('unknown phase', + function() b.parse_gui_commandline( + opts, {'imaname', 'garbagephase'}) end) end function test.parse_commandline()