Hello @Dani_S ,
The current approach is okay, but you could also do something like this:
private static void Main(string[] args)
{
Console.OutputEncoding = System.Text.Encoding.UTF8;
args = EnsureDebugArgs(args);
Environment.Exit(Run(args));
}
public static int Run(string[] args)
{
// apply license FIRST before doing anything else
if (!AsposeLicenseManager.ApplyLicense())
{
Console.Error.WriteLine("failed to apply aspose license.");
Console.Error.WriteLine("the program cannot continue without a valid license.");
return (int)ExitCode.AppError; // <-- RETURN the exit code, don't kill the process
}
// help flags
if (args.Length == 0 || args[0] == "help" || args[0] == "--help" || args[0] == "-h")
{
ShowHelp();
return (int)ExitCode.Success;
}
if (args[0] == "--help-formats")
{
ShowHelpFormats();
return (int)ExitCode.Success;
}
// extract the command from the first argument
string command = args[0].ToLowerInvariant();
try
{
switch (command)
{
case "gis_convert":
return RunGisConverter(args);
default:
Console.WriteLine($"unknown command: {command}\n");
ShowHelp();
return (int)ExitCode.AppError;
}
}
catch (Exception ex)
{
Console.WriteLine("error:");
Console.WriteLine(ex.Message);
return (int)ExitCode.Unexpected;
}
}
Happy holidays.