aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm/confighelp.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-31 17:20:12 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-05-31 17:20:12 +0100
commit98763319d1169ede18cb0470672cc7acb8f0d679 (patch)
tree2a844716829df745102c7c5abdc074253f6d873b /lualib/rspamadm/confighelp.lua
parentc0262caefb3cdc6c3792bfe871e64333aa89783d (diff)
downloadrspamd-98763319d1169ede18cb0470672cc7acb8f0d679.tar.gz
rspamd-98763319d1169ede18cb0470672cc7acb8f0d679.zip
[Project] Deprecate and remove getopt library
Diffstat (limited to 'lualib/rspamadm/confighelp.lua')
-rw-r--r--lualib/rspamadm/confighelp.lua18
1 files changed, 14 insertions, 4 deletions
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)