hactoolnet: Set a different exit code on error

This commit is contained in:
Alex Barney 2019-03-08 12:41:55 -06:00
parent 7904772fc0
commit f85eff4ab7

View file

@ -7,11 +7,11 @@ namespace hactoolnet
{ {
public static class Program public static class Program
{ {
public static void Main(string[] args) public static int Main(string[] args)
{ {
try try
{ {
Run(args); if (Run(args)) return 0;
} }
catch (MissingKeyException ex) catch (MissingKeyException ex)
{ {
@ -26,14 +26,16 @@ namespace hactoolnet
Console.WriteLine(ex.GetType().FullName); Console.WriteLine(ex.GetType().FullName);
Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.StackTrace);
} }
return 1;
} }
private static void Run(string[] args) private static bool Run(string[] args)
{ {
Console.OutputEncoding = Encoding.UTF8; Console.OutputEncoding = Encoding.UTF8;
var ctx = new Context(); var ctx = new Context();
ctx.Options = CliParser.Parse(args); ctx.Options = CliParser.Parse(args);
if (ctx.Options == null) return; if (ctx.Options == null) return false;
using (var logger = new ProgressBar()) using (var logger = new ProgressBar())
{ {
@ -43,11 +45,13 @@ namespace hactoolnet
if (ctx.Options.RunCustom) if (ctx.Options.RunCustom)
{ {
CustomTask(ctx); CustomTask(ctx);
return; return true;
} }
RunTask(ctx); RunTask(ctx);
} }
return true;
} }
private static void RunTask(Context ctx) private static void RunTask(Context ctx)