47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using CommandLine;
|
|
using log4net;
|
|
using System;
|
|
|
|
namespace bsmd.Tool
|
|
{
|
|
public static class Program
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger("Tool");
|
|
|
|
public static int Main(string[] args)
|
|
{
|
|
int result = 0;
|
|
log4net.Config.XmlConfigurator.Configure();
|
|
Options options = new Options();
|
|
try
|
|
{
|
|
Parser.Default.ParseArguments<Options>(args).WithParsed<Options>(o =>
|
|
{
|
|
if (o.CheckRules)
|
|
{
|
|
if (Guid.TryParse(options.MessageCoreId, out Guid coreId))
|
|
{
|
|
CheckRules.Check(coreId);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("cannot parse message core id");
|
|
log.FatalFormat("CheckRules: cannot parse message core id");
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(o.CleanupFolderRoot))
|
|
{
|
|
CleanupFiles.Cleanup(options.CleanupFolderRoot, options.StaleDays, options.CleanupRecursive);
|
|
}
|
|
});
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Fatal(ex.Message);
|
|
result = 1;
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
}
|