Software /
code /
prosody
Comparison
util/startup.lua @ 10936:d770435f0f84
util.argparse: Move exiting and error to util.startup
It's not so nice to have a library that exits the entire application
from under you, so this and the error reporting belongs in util.startup.
The argparse code was originally in util.startup but moved out in
1196f1e8d178 but the error handling should have stayed.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 17 Jun 2020 19:32:12 +0200 |
parent | 10934:b4daa697a7ea |
child | 10948:bebb384090b0 |
comparison
equal
deleted
inserted
replaced
10935:2d57c49bfa12 | 10936:d770435f0f84 |
---|---|
18 | 18 |
19 local short_params = { D = "daemonize", F = "no-daemonize" }; | 19 local short_params = { D = "daemonize", F = "no-daemonize" }; |
20 local value_params = { config = true }; | 20 local value_params = { config = true }; |
21 | 21 |
22 function startup.parse_args() | 22 function startup.parse_args() |
23 prosody.opts = parse_args(arg, { | 23 local opts, err, where = parse_args(arg, { |
24 short_params = short_params, | 24 short_params = short_params, |
25 value_params = value_params, | 25 value_params = value_params, |
26 }); | 26 }); |
27 if not opts then | |
28 if err == "param-not-found" then | |
29 print("Unknown command-line option: "..tostring(where)); | |
30 print("Perhaps you meant to use prosodyctl instead?"); | |
31 elseif err == "missing-value" then | |
32 print("Expected a value to follow command-line option: "..where); | |
33 end | |
34 os.exit(1); | |
35 end | |
36 prosody.opts = opts; | |
27 end | 37 end |
28 | 38 |
29 function startup.read_config() | 39 function startup.read_config() |
30 local filenames = {}; | 40 local filenames = {}; |
31 | 41 |