13 using System.Reflection;
24 new Option { Name =
"config", ArgumentType = ArgumentType.Required, Value =
'c' },
25 new Option { Name =
"log-lvl", ArgumentType = ArgumentType.Required, Value =
'L' },
26 new Option { Name =
"help", ArgumentType = ArgumentType.None, Value =
'h' },
27 new Option { Name =
"version", ArgumentType = ArgumentType.None, Value =
'v' },
28 new Option { Name =
"check-updates", ArgumentType = ArgumentType.None, Value =
'U' },
29 new Option { Name =
"reset-cfg", ArgumentType = ArgumentType.Optional, Value =
'%' },
30 new Option { Name =
"interactive", ArgumentType = ArgumentType.None, Value =
'i' }
40 static async Task<int>
Main(
string[] args) {
42 if (returnCode != 0) {
return returnCode - 1; }
56 return await app.Execute();
74 var consoleSettings =
_cfgManager.GetConsoleLoggerConfig();
75 var fileSettings =
_cfgManager.GetFileLoggerConfig();
78 EnableConsoleOutput = consoleSettings.EnableLogging,
81 EnableFileOutput = fileSettings.EnableLogging
94 var getopt =
new GetOpt {
96 DoubleDashStopsParsing =
true,
103 optChar = getopt.GetNextOpt(out var optArg);
116 if (
string.IsNullOrEmpty(optArg)) {
117 Console.Error.WriteLine(
"Missing argument for --config!");
123 if (
string.IsNullOrEmpty(optArg)) {
124 Console.Error.WriteLine(
"Missing argument for --log-lvl!");
133 Console.Error.WriteLine($
"The argument { optChar } is not yet implemented!");
136 }
while (optChar != -1);
147hermod {0} - A high-performance, cross-platform email archival and search engine
149Usage: (hermod has full getopt support)
150 hermod # no options = normal execution
154 --help, -h Display this entry and exit
155 --version, -v Display the application version and exit
156 --reset-cfg, -% !!! DANGER !!! Resets the configurations to their default values!
159 --config, -c<config> Override the application config file location
160 --log-lvl, -L<lvl> Override the log level: debug, trace, error, warning (default), info, critical
171 var version = Assembly.GetExecutingAssembly().GetName().Version;
173 return $
"v{ version?.Major }.{ version?.MajorRevision }.{ version?.Minor }.{ version?.MinorRevision }";
187 arg = arg?.ToLowerInvariant() ??
string.Empty;
191 return LogEventLevel.Debug;
193 return LogEventLevel.Verbose;
196 return LogEventLevel.Warning;
198 return LogEventLevel.Error;
201 return LogEventLevel.Information;
203 return LogEventLevel.Fatal;
Provides an application-wide, thread safe way of getting and setting configurations relevant to the m...
static ConfigManager Instance
Gets the application-wide instance of the ConfigManager.
Custom logger class for Hermod; internally uses Serilog.
ILogger GetLogger()
Gets the instance of the Serilog logger.
static string GetApplicationVersion()
Gets the application's version string.
static ? LogEventLevel GetLogLevelFromArg(string? arg)
Converts an incoming application argument to its respective log level.
static ? FileInfo _overriddenConfigLocation
static void PrintHelp()
Prints the help text for hermod.
static void PrintVersion()
Prints the application's version.
static ConfigManager _cfgManager
static Option[] _longOpts
static ? ILogger _appLogger
static int ParseArgs(string[] args)
Parses the command-line arguments passed to the application.
static ? LogEventLevel _logLevel
static bool _interactiveMode
static void InitialiseLogger()
Initialises the application's logger.
static async Task< int > Main(string[] args)
static void InitialiseConfigs()
Initialises the application's config manager.