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:
@@ -35,6 +35,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using DiscImageChef.CommonTypes;
|
||||
using DiscImageChef.CommonTypes.Enums;
|
||||
using DiscImageChef.CommonTypes.Interfaces;
|
||||
using DiscImageChef.CommonTypes.Structs;
|
||||
using DiscImageChef.Console;
|
||||
@@ -83,7 +84,7 @@ namespace DiscImageChef.Commands
|
||||
if(showHelp)
|
||||
{
|
||||
Options.WriteOptionDescriptions(CommandSet.Out);
|
||||
return 0;
|
||||
return (int)ErrorNumber.HelpRequested;
|
||||
}
|
||||
|
||||
MainClass.PrintCopyright();
|
||||
@@ -93,13 +94,13 @@ 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;
|
||||
}
|
||||
|
||||
inputFile = extra[0];
|
||||
@@ -124,7 +125,7 @@ namespace DiscImageChef.Commands
|
||||
if(inputFilter == null)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Cannot open specified file.");
|
||||
return 0;
|
||||
return (int)ErrorNumber.CannotOpenFile;
|
||||
}
|
||||
|
||||
Encoding encoding = null;
|
||||
@@ -138,7 +139,7 @@ namespace DiscImageChef.Commands
|
||||
catch(ArgumentException)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Specified encoding is not supported.");
|
||||
return 1;
|
||||
return (int)ErrorNumber.EncodingUnknown;
|
||||
}
|
||||
|
||||
PluginBase plugins = GetPluginBase.Instance;
|
||||
@@ -150,7 +151,7 @@ namespace DiscImageChef.Commands
|
||||
if(imageFormat == null)
|
||||
{
|
||||
DicConsole.WriteLine("Image format not identified, not proceeding with analysis.");
|
||||
return 2;
|
||||
return (int)ErrorNumber.UnrecognizedFormat;
|
||||
}
|
||||
|
||||
if(MainClass.Verbose)
|
||||
@@ -161,7 +162,7 @@ namespace DiscImageChef.Commands
|
||||
if(Directory.Exists(outputDir) || File.Exists(outputDir))
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Destination exists, aborting.");
|
||||
return 3;
|
||||
return (int)ErrorNumber.DestinationExists;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(outputDir);
|
||||
@@ -172,7 +173,7 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
DicConsole.WriteLine("Unable to open image format");
|
||||
DicConsole.WriteLine("No error given");
|
||||
return 4;
|
||||
return (int)ErrorNumber.CannotOpenFormat;
|
||||
}
|
||||
|
||||
DicConsole.DebugWriteLine("Extract-Files command", "Correctly opened image file.");
|
||||
@@ -191,7 +192,7 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Unable to open image format");
|
||||
DicConsole.ErrorWriteLine("Error: {0}", ex.Message);
|
||||
return 5;
|
||||
return (int)ErrorNumber.CannotOpenFormat;
|
||||
}
|
||||
|
||||
List<Partition> partitions = Core.Partitions.GetAll(imageFormat);
|
||||
@@ -797,10 +798,11 @@ namespace DiscImageChef.Commands
|
||||
{
|
||||
DicConsole.ErrorWriteLine($"Error reading file: {ex.Message}");
|
||||
DicConsole.DebugWriteLine("Extract-Files command", ex.StackTrace);
|
||||
return (int)ErrorNumber.UnexpectedException;
|
||||
}
|
||||
|
||||
Statistics.AddCommand("extract-files");
|
||||
return 0;
|
||||
return (int)ErrorNumber.NoError;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user