From 49bca6a5274d28e3aed18fd01290ec7f33f83fee Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 21 Sep 2017 14:53:19 -0400 Subject: [PATCH] Add delete command to CLI --- TGCommandLine/ConfigCommands.cs | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/TGCommandLine/ConfigCommands.cs b/TGCommandLine/ConfigCommands.cs index 47dfee862d..ef2e3df3d9 100644 --- a/TGCommandLine/ConfigCommands.cs +++ b/TGCommandLine/ConfigCommands.cs @@ -10,13 +10,40 @@ namespace TGCommandLine public ConfigCommand() { Keyword = "config"; - Children = new Command[] { new ConfigServerDirectoryCommand(), new ConfigDownloadCommand(), new ConfigUploadCommand(), new ConfigListCommand() }; + Children = new Command[] { new ConfigDeleteCommand(), new ConfigServerDirectoryCommand(), new ConfigDownloadCommand(), new ConfigUploadCommand(), new ConfigListCommand() }; } public override string GetHelpText() { return "Manage settings"; } } + class ConfigDeleteCommand : Command + { + public ConfigDeleteCommand() + { + Keyword = "delete"; + RequiredParameters = 1; + } + + protected override ExitCode Run(IList parameters) + { + var res = Server.GetComponent().DeleteFile(parameters[0], out bool unauthorized); + if (res != null) + { + OutputProc(res); + return ExitCode.ServerError; + } + return ExitCode.Normal; + } + public override string GetArgumentString() + { + return ""; + } + public override string GetHelpText() + { + return "Deletes the specified file from the static tree."; + } + } class ConfigListCommand : Command {