mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
Add options parsing and passing to plugins.
This commit is contained in:
@@ -67,6 +67,12 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.DebugWriteLine("Analyze command", "--drive-model={0}", options.DriveModel);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--drive-serial={0}", options.DriveSerialNumber);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--drive-revision={0}", options.DriveFirmwareRevision);
|
||||
DicConsole.DebugWriteLine("Analyze command", "--options={0}", options.Options);
|
||||
|
||||
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
|
||||
DicConsole.DebugWriteLine("Analyze command", "Parsed options:");
|
||||
foreach(KeyValuePair<string,string> parsedOption in parsedOptions)
|
||||
DicConsole.DebugWriteLine("Analyze command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
|
||||
|
||||
if(options.Count == 0)
|
||||
{
|
||||
@@ -193,7 +199,7 @@ namespace DiscImageChef.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
if(!outputFormat.Create(options.OutputFile, inputFormat.Info.MediaType, new Dictionary<string, string>(),
|
||||
if(!outputFormat.Create(options.OutputFile, inputFormat.Info.MediaType, parsedOptions,
|
||||
inputFormat.Info.Sectors, inputFormat.Info.SectorSize))
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Error {0} creating output image.", outputFormat.ErrorMessage);
|
||||
|
||||
@@ -56,9 +56,13 @@ namespace DiscImageChef.Commands
|
||||
|
||||
FiltersList filtersList = new FiltersList();
|
||||
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
|
||||
Dictionary<string, string> optionsDict =
|
||||
new Dictionary<string, string> {{"debug", options.Debug.ToString()}};
|
||||
|
||||
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
|
||||
DicConsole.DebugWriteLine("Extract-Files command", "Parsed options:");
|
||||
foreach(KeyValuePair<string,string> parsedOption in parsedOptions)
|
||||
DicConsole.DebugWriteLine("Extract-Files command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
|
||||
parsedOptions.Add("debug", options.Debug.ToString());
|
||||
|
||||
if(inputFilter == null)
|
||||
{
|
||||
DicConsole.ErrorWriteLine("Cannot open specified file.");
|
||||
@@ -165,7 +169,7 @@ namespace DiscImageChef.Commands
|
||||
.GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -321,7 +325,7 @@ namespace DiscImageChef.Commands
|
||||
IReadOnlyFilesystem fs = (IReadOnlyFilesystem)plugin
|
||||
.GetType().GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -482,7 +486,7 @@ namespace DiscImageChef.Commands
|
||||
IReadOnlyFilesystem fs = (IReadOnlyFilesystem)plugin
|
||||
.GetType().GetConstructor(Type.EmptyTypes)
|
||||
?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -627,7 +631,7 @@ namespace DiscImageChef.Commands
|
||||
DicConsole.WriteLine($"Identified by {plugin.Name}.");
|
||||
IReadOnlyFilesystem fs =
|
||||
(IReadOnlyFilesystem)plugin.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
|
||||
@@ -52,8 +52,12 @@ namespace DiscImageChef.Commands
|
||||
|
||||
FiltersList filtersList = new FiltersList();
|
||||
IFilter inputFilter = filtersList.GetFilter(options.InputFile);
|
||||
Dictionary<string, string> optionsDict =
|
||||
new Dictionary<string, string> {{"debug", options.Debug.ToString()}};
|
||||
|
||||
Dictionary<string, string> parsedOptions = Options.Parse(options.Options);
|
||||
DicConsole.DebugWriteLine("Ls command", "Parsed options:");
|
||||
foreach(KeyValuePair<string,string> parsedOption in parsedOptions)
|
||||
DicConsole.DebugWriteLine("Ls command", "{0} = {1}", parsedOption.Key, parsedOption.Value);
|
||||
parsedOptions.Add("debug", options.Debug.ToString());
|
||||
|
||||
if(inputFilter == null)
|
||||
{
|
||||
@@ -154,7 +158,7 @@ namespace DiscImageChef.Commands
|
||||
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -184,7 +188,7 @@ namespace DiscImageChef.Commands
|
||||
?.Invoke(new object[] { });
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, partitions[i], encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -224,7 +228,7 @@ namespace DiscImageChef.Commands
|
||||
?.Invoke(new object[] { });
|
||||
if(fs == null) continue;
|
||||
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
@@ -251,7 +255,7 @@ namespace DiscImageChef.Commands
|
||||
.GetType().GetConstructor(Type.EmptyTypes)?.Invoke(new object[] { });
|
||||
if(fs != null)
|
||||
{
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, optionsDict);
|
||||
error = fs.Mount(imageFormat, wholePart, encoding, parsedOptions);
|
||||
if(error == Errno.NoError)
|
||||
{
|
||||
List<string> rootDir = new List<string>();
|
||||
|
||||
@@ -326,6 +326,10 @@ namespace DiscImageChef
|
||||
|
||||
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
|
||||
public string EncodingName { get; set; }
|
||||
|
||||
[Option('O', "options", Default = null,
|
||||
HelpText = "Comma separated name=value pairs of options to pass to filesystem plugin")]
|
||||
public string Options { get; set; }
|
||||
}
|
||||
|
||||
[Verb("extract-files", HelpText = "Extracts all files in disc image.")]
|
||||
@@ -343,6 +347,10 @@ namespace DiscImageChef
|
||||
|
||||
[Option('e', "encoding", Default = null, HelpText = "Name of character encoding to use.")]
|
||||
public string EncodingName { get; set; }
|
||||
|
||||
[Option('O', "options", Default = null,
|
||||
HelpText = "Comma separated name=value pairs of options to pass to filesystem plugin")]
|
||||
public string Options { get; set; }
|
||||
}
|
||||
|
||||
[Verb("list-devices", HelpText = "Lists all connected devices.")]
|
||||
@@ -412,5 +420,9 @@ namespace DiscImageChef
|
||||
HelpText =
|
||||
"Firmware revision of the drive used to read the media represented by the image")]
|
||||
public string DriveFirmwareRevision { get; set; }
|
||||
|
||||
[Option('O', "options", Default = null,
|
||||
HelpText = "Comma separated name=value pairs of options to pass to output image plugin")]
|
||||
public string Options { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user