Console command to enumerate static dir

This commit is contained in:
Cyberboss
2017-09-21 12:22:00 -04:00
parent 2331135860
commit 951eb57ee4
+34 -1
View File
@@ -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<string> parameters)
{
var list = Server.GetComponent<ITGConfig>().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()