implement --format option for minimal and pretty

pretty is currently equivalent to the previous format, though there will
be changes in the future
develop
myk002 2021-09-10 12:46:07 -07:00 committed by Myk
parent 0410aaeaf0
commit 772e386427
3 changed files with 584 additions and 539 deletions

File diff suppressed because it is too large Load Diff

@ -42,6 +42,12 @@ local valid_phase_list = {
}
valid_phases = utils.invert(valid_phase_list)
local valid_formats_list = {
'minimal',
'pretty',
}
valid_formats = utils.invert(valid_formats_list)
local valid_split_strategies_list = {
'none',
'phase',
@ -56,13 +62,20 @@ local function parse_cursor(opts, arg)
utils.assign(opts.start, cursor)
end
local function parse_enum(opts, valid, name, val)
if not valid[val] then
qerror(('unknown %s: "%s"; expected one of: %s')
:format(name, val, table.concat(valid, ', ')))
end
opts[name] = val
end
local function parse_split_strategy(opts, strategy)
if not valid_split_strategies[strategy] then
qerror(('unknown split strategy: "%s"; expected one of: %s')
:format(strategy,
table.concat(valid_split_strategies_list, ', ')))
parse_enum(opts, valid_split_strategies, 'split_strategy', strategy)
end
opts.split_strategy = strategy
local function parse_format(opts, file_format)
parse_enum(opts, valid_formats, 'format', file_format)
end
local function parse_positionals(opts, args, start_argidx)
@ -102,9 +115,15 @@ local function process_args(opts, args)
return
end
-- set defaults
opts.format = valid_formats_list[1]
opts.split_strategy = valid_split_strategies_list[1]
local positionals = argparse.processArgsGetopt(args, {
{'c', 'cursor', hasArg=true,
handler=function(optarg) parse_cursor(opts, optarg) end},
{'f', 'format', hasArg=true,
handler=function(optarg) parse_format(opts, optarg) end},
{'h', 'help', handler=function() opts.help = true end},
{'t', 'splitby', hasArg=true,
handler=function(optarg) parse_split_strategy(opts, optarg) end},
@ -114,7 +133,6 @@ local function process_args(opts, args)
return
end
opts.split_strategy = opts.split_strategy or valid_split_strategies_list[1]
return positionals
end

@ -194,7 +194,7 @@ local function run_blueprint(basename, set, pos)
tostring(set.spec.height),
tostring(-set.spec.depth),
output_dir..basename, get_cursor_arg(pos),
'-tphase'}
'-tphase', '-fpretty'}
for _,mode_name in pairs(mode_names) do
if set.modes[mode_name] then table.insert(blueprint_args, mode_name) end
end
@ -249,7 +249,7 @@ function test.end_to_end()
end
-- run dig-now to dig out designated tiles
dfhack.run_command('dig-now')
dfhack.run_command('dig-now', '--clean')
-- quickfort run remaining blueprints
for _,mode_name in pairs(mode_names) do