From 3dc8d84af1753b41fe37b3b3954731379dc579aa Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Thu, 9 Jul 2020 22:58:22 +0200 Subject: Implement new command for minecctl --- minecctl/minecctl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'minecctl/minecctl.c') diff --git a/minecctl/minecctl.c b/minecctl/minecctl.c index b374f18..3b1da80 100644 --- a/minecctl/minecctl.c +++ b/minecctl/minecctl.c @@ -157,6 +157,7 @@ _noreturn_ static void usage(bool no_error) "\n" "Valid commands:\n" " init perform initial setup\n" + " new SERVER create a new server\n" " list list known servers\n" " lint check validity of server configuration files\n" " info [SERVER] show information about a running SERVER (or all known servers)\n" @@ -178,7 +179,7 @@ _noreturn_ static void usage(bool no_error) " -m, --mc-address=ADDR connect to Minecraft server at ADDR\n" " (only relevant for some commands, can also\n" " use environment variable MC_ADDRESS)\n" - " -c, --cfgdir=DIR look for server configuration files in DIR\n" + " -c, --cfgdir=DIR look for configuration files in DIR\n" " -f, --force stop server even if it has players\n" " -v, --verbose enable extra logging\n" " -d, --debug enable debugging information\n" @@ -324,6 +325,17 @@ static void parse_command(struct cfg *cfg, char *const *argv) } cfg->cmd = do_init; break; + case CMD_NEW: + if (!*argv) { + error("Missing arguments"); + usage(false); + } else if (*(argv + 1)) { + error("Too many arguments"); + usage(false); + } + cfg->commands = strv_copy(argv); + cfg->cmd = do_new; + break; case CMD_LIST: if (*argv) { error("Too many arguments"); -- cgit v1.2.3