summaryrefslogtreecommitdiff
path: root/minecctl/misc-commands.c
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2020-06-30 08:54:52 +0200
committerDavid Härdeman <david@hardeman.nu>2020-06-30 08:54:52 +0200
commit769457c165488fb8059ecb843a1c200f69dce95d (patch)
tree8ea46bc8f22454681130c7ce9958443ca1e4d440 /minecctl/misc-commands.c
parenta89a0f918925a662503c1bcb28bdb06ab9b7ef25 (diff)
Centralize scfg validation and use in minecctl to implement a lint command
Diffstat (limited to 'minecctl/misc-commands.c')
-rw-r--r--minecctl/misc-commands.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/minecctl/misc-commands.c b/minecctl/misc-commands.c
index f20cac5..1268138 100644
--- a/minecctl/misc-commands.c
+++ b/minecctl/misc-commands.c
@@ -17,6 +17,30 @@ bool do_list(struct cfg *cfg)
return true;
}
+bool do_lint(struct cfg *cfg)
+{
+ struct server *server;
+ bool rv = true;
+
+ /* server->scfg.filename check excludes servers created from cmdline */
+ list_for_each_entry(server, &cfg->servers, list) {
+ if (!server->scfg.filename)
+ continue;
+
+ info("%s", server->name);
+
+ /* FIXME: should return bool */
+ server_read_config(cfg, server);
+
+ if (!scfg_validate(&server->scfg)) {
+ error("%s: invalid", server->name);
+ rv = false;
+ }
+ }
+
+ return rv;
+}
+
bool do_pcount(struct cfg *cfg)
{
unsigned x, y;