From 98763319d1169ede18cb0470672cc7acb8f0d679 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 31 May 2018 17:20:12 +0100 Subject: [Project] Deprecate and remove getopt library --- lualib/rspamadm/confighelp.lua | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'lualib/rspamadm/confighelp.lua') diff --git a/lualib/rspamadm/confighelp.lua b/lualib/rspamadm/confighelp.lua index 8f0fd2b7d..d477ff69b 100644 --- a/lualib/rspamadm/confighelp.lua +++ b/lualib/rspamadm/confighelp.lua @@ -1,4 +1,4 @@ -local opts = {} +local opts local known_attrs = { data = 1, example = 1, @@ -6,10 +6,20 @@ local known_attrs = { required = 1, default = 1, } - -local getopt = require "getopt" +local argparse = require "argparse" local ansicolors = require "ansicolors" +local parser = argparse() + :name "rspamadm confighelp" + :description "Shows help for the specified configuration options" + :help_description_margin(32) +parser:flag "--no-color" + :description "Disable coloured output" +parser:flag "--short" + :description "Show only option names" +parser:flag "--no-examples" + :description "Do not show examples (impied by --short)" + local function maybe_print_color(key) if not opts['no-color'] then return ansicolors.white .. key .. ansicolors.reset @@ -100,7 +110,7 @@ local function print_help(key, value, tabs) end return function(args, res) - opts = getopt.getopt(args, '') + opts = parser:parse(args) local sorted = sort_values(res) -- cgit v1.2.3