Add support to show available options from IReadOnlyFilesystems.

This commit is contained in:
2017-12-28 00:29:04 +00:00
parent a1f82e0e72
commit 1bb2d16e54
14 changed files with 269 additions and 152 deletions

View File

@@ -32,6 +32,7 @@
<e p="Formats.cs" t="Include" /> <e p="Formats.cs" t="Include" />
<e p="ListDevices.cs" t="Include" /> <e p="ListDevices.cs" t="Include" />
<e p="ListEncodings.cs" t="Include" /> <e p="ListEncodings.cs" t="Include" />
<e p="ListOptions.cs" t="Include" />
<e p="Ls.cs" t="Include" /> <e p="Ls.cs" t="Include" />
<e p="MediaInfo.cs" t="Include" /> <e p="MediaInfo.cs" t="Include" />
<e p="MediaScan.cs" t="Include" /> <e p="MediaScan.cs" t="Include" />

View File

@@ -57,6 +57,11 @@ namespace DiscImageChef.Filesystems.AppleDOS
public string Name => "Apple DOS File System"; public string Name => "Apple DOS File System";
public Guid Id => new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n"); public Guid Id => new Guid("8658A1E9-B2E7-4BCC-9638-157A31B0A700\n");
public (string name, Type type, string description)[] ListOptions()
{
return new(string name, Type type, string description)[] { };
}
static Dictionary<string, string> GetDefaultOptions() static Dictionary<string, string> GetDefaultOptions()
{ {
return new Dictionary<string, string> {{"debug", false.ToString()}}; return new Dictionary<string, string> {{"debug", false.ToString()}};

View File

@@ -71,5 +71,11 @@ namespace DiscImageChef.Filesystems.AppleMFS
{ {
return new Dictionary<string, string> {{"debug", false.ToString()}}; return new Dictionary<string, string> {{"debug", false.ToString()}};
} }
// TODO: Implement Finder namespace (requires decoding Desktop database)
public (string name, Type type, string description)[] ListOptions()
{
return new(string name, Type type, string description)[] { };
}
} }
} }

View File

@@ -117,6 +117,11 @@ namespace DiscImageChef.Filesystems.CPM
public string Name => "CP/M File System"; public string Name => "CP/M File System";
public Guid Id => new Guid("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1"); public Guid Id => new Guid("AA2B8585-41DF-4E3B-8A35-D1A935E2F8A1");
public (string name, Type type, string description)[] ListOptions()
{
return new(string name, Type type, string description)[] { };
}
static Dictionary<string, string> GetDefaultOptions() static Dictionary<string, string> GetDefaultOptions()
{ {
return new Dictionary<string, string> {{"debug", false.ToString()}}; return new Dictionary<string, string> {{"debug", false.ToString()}};

View File

@@ -35,6 +35,9 @@
<HintPath>..\packages\Claunia.Encoding.1.4.0\lib\portable40-net40+sl5+win8+wp8\Claunia.Encoding.dll</HintPath> <HintPath>..\packages\Claunia.Encoding.1.4.0\lib\portable40-net40+sl5+win8+wp8\Claunia.Encoding.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -31,6 +31,7 @@
// Copyright © 2011-2018 Natalia Portillo // Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/ // ****************************************************************************/
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using DiscImageChef.CommonTypes; using DiscImageChef.CommonTypes;
@@ -129,5 +130,10 @@ namespace DiscImageChef.Filesystems
/// <param name="path">Link path.</param> /// <param name="path">Link path.</param>
/// <param name="dest">Link destination.</param> /// <param name="dest">Link destination.</param>
Errno ReadLink(string path, out string dest); Errno ReadLink(string path, out string dest);
/// <summary>
/// Retrieves a list of options supported by the filesystem, with name, type and description
/// </summary>
(string name, Type type, string description)[] ListOptions();
} }
} }

View File

@@ -56,6 +56,12 @@ namespace DiscImageChef.Filesystems.LisaFS
public Encoding Encoding { get; private set; } public Encoding Encoding { get; private set; }
public FileSystemType XmlFsType { get; private set; } public FileSystemType XmlFsType { get; private set; }
// TODO: Implement Lisa 7/7 namespace (needs decoding {!CATALOG} file)
public (string name, Type type, string description)[] ListOptions()
{
return new(string name, Type type, string description)[] { };
}
static Dictionary<string, string> GetDefaultOptions() static Dictionary<string, string> GetDefaultOptions()
{ {
return new Dictionary<string, string> {{"debug", false.ToString()}}; return new Dictionary<string, string> {{"debug", false.ToString()}};

View File

@@ -73,6 +73,11 @@ namespace DiscImageChef.Filesystems.UCSDPascal
return Errno.NotSupported; return Errno.NotSupported;
} }
public (string name, Type type, string description)[] ListOptions()
{
return new(string name, Type type, string description)[] { };
}
static Dictionary<string, string> GetDefaultOptions() static Dictionary<string, string> GetDefaultOptions()
{ {
return new Dictionary<string, string> {{"debug", false.ToString()}}; return new Dictionary<string, string> {{"debug", false.ToString()}};

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Claunia.Encoding" version="1.4.0" targetFramework="net40" /> <package id="Claunia.Encoding" version="1.4.0" targetFramework="net40" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net40" />
</packages> </packages>

View File

@@ -0,0 +1,61 @@
// /***************************************************************************
// The Disc Image Chef
// ----------------------------------------------------------------------------
//
// Filename : ListOptions.cs
// Author(s) : Natalia Portillo <claunia@claunia.com>
//
// Component : Verbs.
//
// --[ Description ] ----------------------------------------------------------
//
// Lists all options supported by read-only filesystems.
//
// --[ License ] --------------------------------------------------------------
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// ----------------------------------------------------------------------------
// Copyright © 2011-2018 Natalia Portillo
// ****************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using DiscImageChef.Console;
using DiscImageChef.Core;
using DiscImageChef.Filesystems;
namespace DiscImageChef.Commands
{
static class ListOptions
{
internal static void DoList()
{
PluginBase plugins = new PluginBase();
foreach(KeyValuePair<string, IReadOnlyFilesystem> kvp in plugins.ReadOnlyFilesystems)
{
List<(string name, Type type, string description)> options = kvp.Value.ListOptions().ToList();
options.Add(("debug", typeof(bool), "Enables debug features if available"));
DicConsole.WriteLine("Options for {0}:", kvp.Value.Name);
DicConsole.WriteLine("{0,-16} {1,-16} {2,-8}", "Name", "Type", "Description");
foreach((string name, Type type, string description) option in options.OrderBy(t => t.name))
DicConsole.WriteLine("{0,-16} {1,-16} {2,-8}", option.name, option.type, option.description);
DicConsole.WriteLine();
}
}
}
}

View File

@@ -45,9 +45,13 @@
<Reference Include="CommandLine"> <Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.2.1.1-beta\lib\net40\CommandLine.dll</HintPath> <HintPath>..\packages\CommandLineParser.2.1.1-beta\lib\net40\CommandLine.dll</HintPath>
</Reference> </Reference>
<Reference Include="System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51">
<HintPath>..\packages\System.ValueTuple.4.4.0\lib\portable-net40+sl4+win8+wp8\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Commands\ListOptions.cs" />
<Compile Include="Main.cs" /> <Compile Include="Main.cs" />
<Compile Include="AssemblyInfo.cs" /> <Compile Include="AssemblyInfo.cs" />
<Compile Include="Options.cs" /> <Compile Include="Options.cs" />

View File

@@ -58,7 +58,8 @@ namespace DiscImageChef
typeof(CreateSidecarOptions), typeof(DumpMediaOptions), typeof(CreateSidecarOptions), typeof(DumpMediaOptions),
typeof(DeviceReportOptions), typeof(ConfigureOptions), typeof(StatsOptions), typeof(DeviceReportOptions), typeof(ConfigureOptions), typeof(StatsOptions),
typeof(LsOptions), typeof(ExtractFilesOptions), typeof(ListDevicesOptions), typeof(LsOptions), typeof(ExtractFilesOptions), typeof(ListDevicesOptions),
typeof(ListEncodingsOptions)).WithParsed<AnalyzeOptions>(opts => typeof(ListEncodingsOptions), typeof(ListOptionsOptions))
.WithParsed<AnalyzeOptions>(opts =>
{ {
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine; if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
@@ -172,6 +173,12 @@ namespace DiscImageChef
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine; if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright(); PrintCopyright();
ListEncodings.DoList(); ListEncodings.DoList();
}).WithParsed<ListOptionsOptions>(opts =>
{
if(opts.Debug) DicConsole.DebugWriteLineEvent += System.Console.Error.WriteLine;
if(opts.Verbose) DicConsole.VerboseWriteLineEvent += System.Console.WriteLine;
PrintCopyright();
ListOptions.DoList();
}).WithParsed<ConfigureOptions>(opts => }).WithParsed<ConfigureOptions>(opts =>
{ {
PrintCopyright(); PrintCopyright();
@@ -187,9 +194,11 @@ namespace DiscImageChef
static void PrintCopyright() static void PrintCopyright()
{ {
object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false); object[] attributes =
typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
string assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title; string assemblyTitle = ((AssemblyTitleAttribute)attributes[0]).Title;
attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false); attributes =
typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
Version assemblyVersion = typeof(MainClass).Assembly.GetName().Version; Version assemblyVersion = typeof(MainClass).Assembly.GetName().Version;
string assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright; string assemblyCopyright = ((AssemblyCopyrightAttribute)attributes[0]).Copyright;

View File

@@ -130,7 +130,8 @@ namespace DiscImageChef
public class EntropyOptions : CommonOptions public class EntropyOptions : CommonOptions
{ {
[Option('p', "duplicated-sectors", Default = true, [Option('p', "duplicated-sectors", Default = true,
HelpText = "Calculates how many sectors are duplicated (have same exact data in user area).")] HelpText =
"Calculates how many sectors are duplicated (have same exact data in user area).")]
public bool DuplicatedSectors { get; set; } public bool DuplicatedSectors { get; set; }
[Option('t', "separated-tracks", Default = true, HelpText = "Calculates entropy for each track separately.")] [Option('t', "separated-tracks", Default = true, HelpText = "Calculates entropy for each track separately.")]
@@ -349,4 +350,7 @@ namespace DiscImageChef
[Verb("list-encodings", HelpText = "Lists all supported text encodings and code pages.")] [Verb("list-encodings", HelpText = "Lists all supported text encodings and code pages.")]
public class ListEncodingsOptions : CommonOptions { } public class ListEncodingsOptions : CommonOptions { }
[Verb("list-options", HelpText = "Lists all options supported by read-only filesystems.")]
public class ListOptionsOptions : CommonOptions { }
} }

View File

@@ -3,4 +3,5 @@
<package id="Claunia.Encoding" version="1.4.0" targetFramework="net40" /> <package id="Claunia.Encoding" version="1.4.0" targetFramework="net40" />
<package id="CommandLineParser" version="2.1.1-beta" targetFramework="net40" /> <package id="CommandLineParser" version="2.1.1-beta" targetFramework="net40" />
<package id="SharpCompress" version="0.19.2" targetFramework="net40" /> <package id="SharpCompress" version="0.19.2" targetFramework="net40" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net40" />
</packages> </packages>