From 951eb57ee4d24dc7b7be8481478cf2760e4a9f1d Mon Sep 17 00:00:00 2001 From: Cyberboss Date: Thu, 21 Sep 2017 12:20:11 -0400 Subject: [PATCH] Console command to enumerate static dir --- TGCommandLine/ConfigCommands.cs | 35 ++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/TGCommandLine/ConfigCommands.cs b/TGCommandLine/ConfigCommands.cs index e95c7d482a..2d1b4e0a22 100644 --- a/TGCommandLine/ConfigCommands.cs +++ b/TGCommandLine/ConfigCommands.cs @@ -10,7 +10,7 @@ namespace TGCommandLine public ConfigCommand() { Keyword = "config"; - Children = new Command[] { new ConfigServerDirectoryCommand(), new ConfigDownloadCommand(), new ConfigUploadCommand() }; + Children = new Command[] { new ConfigServerDirectoryCommand(), new ConfigDownloadCommand(), new ConfigUploadCommand(), new ConfigListCommand() }; } public override string GetHelpText() { @@ -18,6 +18,39 @@ namespace TGCommandLine } } + class ConfigListCommand : Command + { + public ConfigListCommand() + { + Keyword = "list"; + } + + public override string GetHelpText() + { + return "Lists the contents of the server's static directory, optionally specifying a subdirectory"; + } + + public override string GetArgumentString() + { + return "[path to subdirectory]"; + } + protected override ExitCode Run(IList parameters) + { + var list = Server.GetComponent().ListStaticDirectory(parameters.Count > 0 ? parameters[0] : null, out string error); + if(list == null) + { + OutputProc(error); + return ExitCode.ServerError; + } + if (list.Count == 0) + OutputProc("The static directory is empty!"); + else + foreach (var I in list) + OutputProc(I); + return ExitCode.Normal; + } + } + class ConfigServerDirectoryCommand : Command { public ConfigServerDirectoryCommand()