util.argparse
util.argparse
parses command line arguments and is used by the prosody and prosodyctl executables.
Example
#!/usr/bin/lua
local argparse = require "util.argparse";
local opts = argparse.parse(arg, { -- 'arg' is set by Lua
-- -h is the same as --help
= {
short_params = "help";
h };
-- --user requires a parameter
= {
value_params = true;
user };
});
if opts.help then
print("example.lua [-h|--help] [--user{=}USER]")
os.exit(0);
end
print("Hello, "..(opts.user or "World!"))