mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Return specific error codes from command execution.
This commit is contained in:
@@ -32,6 +32,7 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.Console;
|
||||
using DiscImageChef.Core;
|
||||
@@ -73,7 +74,7 @@ namespace DiscImageChef.Commands
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return 0;
|
||||
return (int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
@@ -83,19 +84,19 @@ namespace DiscImageChef.Commands
|
||||
if(extra.Count > 1)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Too many arguments.");
|
||||
return 1;
|
||||
return (int)ErrorNumber.UnexpectedArgumentCount;
|
||||
}
|
||||
|
||||
if(extra.Count == 0)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing input image.");
|
||||
return 1;
|
||||
return (int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
if(startSector is null)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Missing starting sector.");
|
||||
return 1;
|
||||
return (int)ErrorNumber.MissingArgument;
|
||||
}
|
||||
|
||||
inputFile = extra[0];
|
||||
@@ -114,7 +115,7 @@ namespace DiscImageChef.Commands
|
||||
if(inputFilter == null)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Cannot open specified file.");
|
||||
return 1;
|
||||
return (int)ErrorNumber.CannotOpenFile;
|
||||
}
|
||||
|
||||
IMediaImage inputFormat = ImageFormat.Detect(inputFilter);
|
||||
@@ -122,7 +123,7 @@ namespace DiscImageChef.Commands
|
||||
if(inputFormat == null)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Unable to recognize image format, not verifying");
|
||||
return 2;
|
||||
return (int)ErrorNumber.UnrecognizedFormat;
|
||||
}
|
||||
|
||||
inputFormat.Open(inputFilter);
|
||||
@@ -155,7 +156,7 @@ namespace DiscImageChef.Commands
|
||||
}
|
||||
|
||||
Statistics.AddCommand("print-hex");
|
||||
return 0;
|
||||
return (int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user