Comparison

tools/cfgdump.lua @ 11570:c3896c714a83

tools/cfgdump: Serialize individual (table) settings in stable order too
author Kim Alvefur <zash@zash.se>
date Mon, 17 May 2021 16:51:11 +0200
parent 11569:08dab7df152b
child 13142:879a6a33c21b
comparison
equal deleted inserted replaced
11569:08dab7df152b 11570:c3896c714a83
3 -- cfgdump.lua prosody.cfg.lua [[host] option] 3 -- cfgdump.lua prosody.cfg.lua [[host] option]
4 4
5 local s_format, print = string.format, print; 5 local s_format, print = string.format, print;
6 local printf = function(fmt, ...) return print(s_format(fmt, ...)); end 6 local printf = function(fmt, ...) return print(s_format(fmt, ...)); end
7 local it = require "util.iterators"; 7 local it = require "util.iterators";
8 local serialization = require"util.serialization"; 8 local function sort_anything(a, b)
9 local serialize = serialization.new and serialization.new({ unquoted = true }) or serialization.serialize; 9 local typeof_a, typeof_b = type(a), type(b);
10 if typeof_a ~= typeof_b then return typeof_a < typeof_b end
11 return a < b -- should work for everything in a config file
12 end
13 local serialization = require "util.serialization";
14 local serialize = serialization.new and serialization.new({
15 unquoted = true, table_iterator = function(t) return it.sorted_pairs(t, sort_anything); end,
16 }) or serialization.serialize;
10 local configmanager = require"core.configmanager"; 17 local configmanager = require"core.configmanager";
11 local startup = require "util.startup"; 18 local startup = require "util.startup";
12 19
13 startup.set_function_metatable(); 20 startup.set_function_metatable();
14 local config_filename, onlyhost, onlyoption = ...; 21 local config_filename, onlyhost, onlyoption = ...;