From 684122e94cb6357f7c255e838489cfe8ad39ffde Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Fri, 3 Jan 2020 17:41:19 +0000 Subject: [PATCH] Move commands to families. --- .../.idea/contentModel.xml | 59 ++++++++++++------- DiscImageChef.sln.DotSettings | 1 + .../Commands/Database/DatabaseFamily.cs | 48 +++++++++++++++ .../Commands/{ => Database}/Statistics.cs | 0 .../Commands/{ => Database}/Update.cs | 0 DiscImageChef/Commands/Device/DeviceFamily.cs | 49 +++++++++++++++ .../Commands/{ => Device}/DeviceInfo.cs | 7 +-- .../Commands/{ => Device}/DeviceReport.cs | 7 +-- .../Commands/{ => Device}/ListDevices.cs | 9 +-- .../Commands/{ => Filesystem}/ExtractFiles.cs | 4 +- .../Commands/Filesystem/FilesystemFamily.cs | 49 +++++++++++++++ .../Commands/{ => Filesystem}/ListOptions.cs | 0 DiscImageChef/Commands/{ => Filesystem}/Ls.cs | 0 DiscImageChef/Commands/{ => Image}/Analyze.cs | 5 +- .../Commands/{ => Image}/Checksum.cs | 2 +- DiscImageChef/Commands/{ => Image}/Compare.cs | 2 +- .../Commands/{ => Image}/ConvertImage.cs | 8 +-- .../Commands/{ => Image}/CreateSidecar.cs | 5 +- DiscImageChef/Commands/{ => Image}/Decode.cs | 6 +- DiscImageChef/Commands/{ => Image}/Entropy.cs | 6 +- DiscImageChef/Commands/Image/ImageFamily.cs | 55 +++++++++++++++++ .../Commands/{ => Image}/ImageInfo.cs | 2 +- .../Commands/{ => Image}/PrintHex.cs | 6 +- DiscImageChef/Commands/{ => Image}/Verify.cs | 5 +- .../Commands/{ => Media}/DumpMedia.cs | 4 +- DiscImageChef/Commands/Media/MediaFamily.cs | 48 +++++++++++++++ .../Commands/{ => Media}/MediaInfo.cs | 9 ++- .../Commands/{ => Media}/MediaScan.cs | 4 +- DiscImageChef/DiscImageChef.csproj | 53 +++++++++-------- DiscImageChef/Main.cs | 31 ++++------ 30 files changed, 373 insertions(+), 111 deletions(-) create mode 100644 DiscImageChef/Commands/Database/DatabaseFamily.cs rename DiscImageChef/Commands/{ => Database}/Statistics.cs (100%) rename DiscImageChef/Commands/{ => Database}/Update.cs (100%) create mode 100644 DiscImageChef/Commands/Device/DeviceFamily.cs rename DiscImageChef/Commands/{ => Device}/DeviceInfo.cs (99%) rename DiscImageChef/Commands/{ => Device}/DeviceReport.cs (99%) rename DiscImageChef/Commands/{ => Device}/ListDevices.cs (90%) rename DiscImageChef/Commands/{ => Filesystem}/ExtractFiles.cs (99%) create mode 100644 DiscImageChef/Commands/Filesystem/FilesystemFamily.cs rename DiscImageChef/Commands/{ => Filesystem}/ListOptions.cs (100%) rename DiscImageChef/Commands/{ => Filesystem}/Ls.cs (100%) rename DiscImageChef/Commands/{ => Image}/Analyze.cs (98%) rename DiscImageChef/Commands/{ => Image}/Checksum.cs (99%) rename DiscImageChef/Commands/{ => Image}/Compare.cs (99%) rename DiscImageChef/Commands/{ => Image}/ConvertImage.cs (99%) rename DiscImageChef/Commands/{ => Image}/CreateSidecar.cs (98%) rename DiscImageChef/Commands/{ => Image}/Decode.cs (99%) rename DiscImageChef/Commands/{ => Image}/Entropy.cs (97%) create mode 100644 DiscImageChef/Commands/Image/ImageFamily.cs rename DiscImageChef/Commands/{ => Image}/ImageInfo.cs (99%) rename DiscImageChef/Commands/{ => Image}/PrintHex.cs (97%) rename DiscImageChef/Commands/{ => Image}/Verify.cs (98%) rename DiscImageChef/Commands/{ => Media}/DumpMedia.cs (99%) create mode 100644 DiscImageChef/Commands/Media/MediaFamily.cs rename DiscImageChef/Commands/{ => Media}/MediaInfo.cs (99%) rename DiscImageChef/Commands/{ => Media}/MediaScan.cs (98%) diff --git a/.idea/.idea.DiscImageChef/.idea/contentModel.xml b/.idea/.idea.DiscImageChef/.idea/contentModel.xml index 41a5acc6d..c9d916706 100644 --- a/.idea/.idea.DiscImageChef/.idea/contentModel.xml +++ b/.idea/.idea.DiscImageChef/.idea/contentModel.xml @@ -3,8 +3,10 @@ + + @@ -24,33 +26,48 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + - - - - - + + + + + + - - - diff --git a/DiscImageChef.sln.DotSettings b/DiscImageChef.sln.DotSettings index 804f6acf2..1ff89100e 100644 --- a/DiscImageChef.sln.DotSettings +++ b/DiscImageChef.sln.DotSettings @@ -199,6 +199,7 @@ True True True + True True True True diff --git a/DiscImageChef/Commands/Database/DatabaseFamily.cs b/DiscImageChef/Commands/Database/DatabaseFamily.cs new file mode 100644 index 000000000..3c2d26f03 --- /dev/null +++ b/DiscImageChef/Commands/Database/DatabaseFamily.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : DatabaseFamily.cs +// Author(s) : Natalia Portillo +// +// Component : Verbs. +// +// --[ Description ] ---------------------------------------------------------- +// +// Implements the 'database' verb. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.CommandLine; + +namespace DiscImageChef.Commands.Filesystem +{ + public class DatabaseFamily : Command + { + public DatabaseFamily(bool masterDbUpdate) : base("database", + "Commands to manage the device and statistics database") + { + AddAlias("db"); + + AddCommand(new StatisticsCommand()); + AddCommand(new UpdateCommand(masterDbUpdate)); + } + } +} \ No newline at end of file diff --git a/DiscImageChef/Commands/Statistics.cs b/DiscImageChef/Commands/Database/Statistics.cs similarity index 100% rename from DiscImageChef/Commands/Statistics.cs rename to DiscImageChef/Commands/Database/Statistics.cs diff --git a/DiscImageChef/Commands/Update.cs b/DiscImageChef/Commands/Database/Update.cs similarity index 100% rename from DiscImageChef/Commands/Update.cs rename to DiscImageChef/Commands/Database/Update.cs diff --git a/DiscImageChef/Commands/Device/DeviceFamily.cs b/DiscImageChef/Commands/Device/DeviceFamily.cs new file mode 100644 index 000000000..154748736 --- /dev/null +++ b/DiscImageChef/Commands/Device/DeviceFamily.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : DeviceFamily.cs +// Author(s) : Natalia Portillo +// +// Component : Verbs. +// +// --[ Description ] ---------------------------------------------------------- +// +// Implements the 'image' verb. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.CommandLine; + +namespace DiscImageChef.Commands.Device +{ + public class DeviceFamily : Command + { + public DeviceFamily() : base("device", "Commands that talks to devices") + { + AddAlias("d"); + AddAlias("dev"); + + AddCommand(new DeviceInfoCommand()); + AddCommand(new DeviceReportCommand()); + AddCommand(new ListDevicesCommand()); + } + } +} \ No newline at end of file diff --git a/DiscImageChef/Commands/DeviceInfo.cs b/DiscImageChef/Commands/Device/DeviceInfo.cs similarity index 99% rename from DiscImageChef/Commands/DeviceInfo.cs rename to DiscImageChef/Commands/Device/DeviceInfo.cs index 3b4d973e8..ac26088f9 100644 --- a/DiscImageChef/Commands/DeviceInfo.cs +++ b/DiscImageChef/Commands/Device/DeviceInfo.cs @@ -46,10 +46,9 @@ using DiscImageChef.Decoders.SCSI.MMC; using DiscImageChef.Decoders.SCSI.SSC; using DiscImageChef.Devices; using Command = System.CommandLine.Command; -using Device = DiscImageChef.Devices.Device; using DeviceInfo = DiscImageChef.Core.Devices.Info.DeviceInfo; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Device { internal class DeviceInfoCommand : Command { @@ -94,11 +93,11 @@ namespace DiscImageChef.Commands char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + Devices.Device dev; try { - dev = new Device(devicePath); + dev = new Devices.Device(devicePath); if(dev.IsRemote) Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem, diff --git a/DiscImageChef/Commands/DeviceReport.cs b/DiscImageChef/Commands/Device/DeviceReport.cs similarity index 99% rename from DiscImageChef/Commands/DeviceReport.cs rename to DiscImageChef/Commands/Device/DeviceReport.cs index 98b681f50..667b4177a 100644 --- a/DiscImageChef/Commands/DeviceReport.cs +++ b/DiscImageChef/Commands/Device/DeviceReport.cs @@ -48,10 +48,9 @@ using DiscImageChef.Decoders.SCSI; using DiscImageChef.Devices; using Newtonsoft.Json; using Command = System.CommandLine.Command; -using Device = DiscImageChef.Devices.Device; using DeviceReport = DiscImageChef.Core.Devices.Report.DeviceReport; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Device { internal class DeviceReportCommand : Command { @@ -88,11 +87,11 @@ namespace DiscImageChef.Commands char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + Devices.Device dev; try { - dev = new Device(devicePath); + dev = new Devices.Device(devicePath); if(dev.IsRemote) Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem, diff --git a/DiscImageChef/Commands/ListDevices.cs b/DiscImageChef/Commands/Device/ListDevices.cs similarity index 90% rename from DiscImageChef/Commands/ListDevices.cs rename to DiscImageChef/Commands/Device/ListDevices.cs index 6ecf22931..dd54ee4b6 100644 --- a/DiscImageChef/Commands/ListDevices.cs +++ b/DiscImageChef/Commands/Device/ListDevices.cs @@ -67,10 +67,11 @@ namespace DiscImageChef.Commands DicConsole.DebugWriteLine("List-Devices command", "--debug={0}", debug); DicConsole.DebugWriteLine("List-Devices command", "--verbose={0}", verbose); - DeviceInfo[] devices = Device.ListDevices(out bool isRemote, out string serverApplication, - out string serverVersion, out string serverOperatingSystem, - out string serverOperatingSystemVersion, - out string serverArchitecture, dicRemoteHost); + DeviceInfo[] devices = Devices.Device.ListDevices(out bool isRemote, out string serverApplication, + out string serverVersion, + out string serverOperatingSystem, + out string serverOperatingSystemVersion, + out string serverArchitecture, dicRemoteHost); if(isRemote) { diff --git a/DiscImageChef/Commands/ExtractFiles.cs b/DiscImageChef/Commands/Filesystem/ExtractFiles.cs similarity index 99% rename from DiscImageChef/Commands/ExtractFiles.cs rename to DiscImageChef/Commands/Filesystem/ExtractFiles.cs index a5abe1516..d9be4a755 100644 --- a/DiscImageChef/Commands/ExtractFiles.cs +++ b/DiscImageChef/Commands/Filesystem/ExtractFiles.cs @@ -97,8 +97,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool debug, bool verbose, string encoding, bool xattrs, string imagePath, string @namespace, - string outputDir, string options) + public static int Invoke(bool debug, bool verbose, string encoding, bool xattrs, string imagePath, + string @namespace, string outputDir, string options) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Filesystem/FilesystemFamily.cs b/DiscImageChef/Commands/Filesystem/FilesystemFamily.cs new file mode 100644 index 000000000..248b65ff8 --- /dev/null +++ b/DiscImageChef/Commands/Filesystem/FilesystemFamily.cs @@ -0,0 +1,49 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : FilesystemFamily.cs +// Author(s) : Natalia Portillo +// +// Component : Verbs. +// +// --[ Description ] ---------------------------------------------------------- +// +// Implements the 'image' verb. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.CommandLine; + +namespace DiscImageChef.Commands.Filesystem +{ + public class FilesystemFamily : Command + { + public FilesystemFamily() : base("filesystem", "Commands to manage filesystems") + { + AddAlias("fi"); + AddAlias("fs"); + + AddCommand(new ListOptionsCommand()); + AddCommand(new ExtractFilesCommand()); + AddCommand(new LsCommand()); + } + } +} \ No newline at end of file diff --git a/DiscImageChef/Commands/ListOptions.cs b/DiscImageChef/Commands/Filesystem/ListOptions.cs similarity index 100% rename from DiscImageChef/Commands/ListOptions.cs rename to DiscImageChef/Commands/Filesystem/ListOptions.cs diff --git a/DiscImageChef/Commands/Ls.cs b/DiscImageChef/Commands/Filesystem/Ls.cs similarity index 100% rename from DiscImageChef/Commands/Ls.cs rename to DiscImageChef/Commands/Filesystem/Ls.cs diff --git a/DiscImageChef/Commands/Analyze.cs b/DiscImageChef/Commands/Image/Analyze.cs similarity index 98% rename from DiscImageChef/Commands/Analyze.cs rename to DiscImageChef/Commands/Image/Analyze.cs index 909851d6b..d881b85ee 100644 --- a/DiscImageChef/Commands/Analyze.cs +++ b/DiscImageChef/Commands/Image/Analyze.cs @@ -41,7 +41,7 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Console; using DiscImageChef.Core; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class AnalyzeCommand : Command { @@ -80,7 +80,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(typeof(AnalyzeCommand).GetMethod(nameof(Invoke))); } - public static int Invoke(bool verbose, bool debug, string encoding, bool filesystems, bool partitions, string imagePath) + public static int Invoke(bool verbose, bool debug, string encoding, bool filesystems, bool partitions, + string imagePath) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Checksum.cs b/DiscImageChef/Commands/Image/Checksum.cs similarity index 99% rename from DiscImageChef/Commands/Checksum.cs rename to DiscImageChef/Commands/Image/Checksum.cs index 985417309..e57f92365 100644 --- a/DiscImageChef/Commands/Checksum.cs +++ b/DiscImageChef/Commands/Image/Checksum.cs @@ -42,7 +42,7 @@ using DiscImageChef.Console; using DiscImageChef.Core; using Schemas; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class ChecksumCommand : Command { diff --git a/DiscImageChef/Commands/Compare.cs b/DiscImageChef/Commands/Image/Compare.cs similarity index 99% rename from DiscImageChef/Commands/Compare.cs rename to DiscImageChef/Commands/Image/Compare.cs index f4f73f8df..edc80cbd1 100644 --- a/DiscImageChef/Commands/Compare.cs +++ b/DiscImageChef/Commands/Image/Compare.cs @@ -43,7 +43,7 @@ using DiscImageChef.Console; using DiscImageChef.Core; using ImageInfo = DiscImageChef.CommonTypes.Structs.ImageInfo; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class CompareCommand : Command { diff --git a/DiscImageChef/Commands/ConvertImage.cs b/DiscImageChef/Commands/Image/ConvertImage.cs similarity index 99% rename from DiscImageChef/Commands/ConvertImage.cs rename to DiscImageChef/Commands/Image/ConvertImage.cs index cc4868e28..1b3cb32bb 100644 --- a/DiscImageChef/Commands/ConvertImage.cs +++ b/DiscImageChef/Commands/Image/ConvertImage.cs @@ -48,7 +48,7 @@ using Schemas; using ImageInfo = DiscImageChef.CommonTypes.Structs.ImageInfo; using Version = DiscImageChef.CommonTypes.Interop.Version; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class ConvertImageCommand : Command { @@ -193,9 +193,9 @@ namespace DiscImageChef.Commands public static int Invoke(bool verbose, bool debug, string cicmXml, string comments, int count, string creator, string driveFirmwareRevision, string driveManufacturer, string driveModel, string driveSerialNumber, bool force, string inputPath, int lastMediaSequence, - string mediaBarcode, string mediaManufacturer, string mediaModel, string mediaPartNumber, - int mediaSequence, string mediaSerialNumber, string mediaTitle, string outputPath, - string outputOptions, string resumeFile, string format) + string mediaBarcode, string mediaManufacturer, string mediaModel, + string mediaPartNumber, int mediaSequence, string mediaSerialNumber, string mediaTitle, + string outputPath, string outputOptions, string resumeFile, string format) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/CreateSidecar.cs b/DiscImageChef/Commands/Image/CreateSidecar.cs similarity index 98% rename from DiscImageChef/Commands/CreateSidecar.cs rename to DiscImageChef/Commands/Image/CreateSidecar.cs index a3916cb3f..f2c4bff4f 100644 --- a/DiscImageChef/Commands/CreateSidecar.cs +++ b/DiscImageChef/Commands/Image/CreateSidecar.cs @@ -45,7 +45,7 @@ using DiscImageChef.Console; using DiscImageChef.Core; using Schemas; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class CreateSidecarCommand : Command { @@ -85,7 +85,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool debug, bool verbose, uint blockSize, string encodingName, string imagePath, bool tape) + public static int Invoke(bool debug, bool verbose, uint blockSize, string encodingName, string imagePath, + bool tape) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Decode.cs b/DiscImageChef/Commands/Image/Decode.cs similarity index 99% rename from DiscImageChef/Commands/Decode.cs rename to DiscImageChef/Commands/Image/Decode.cs index 5390e4181..f824ad620 100644 --- a/DiscImageChef/Commands/Decode.cs +++ b/DiscImageChef/Commands/Image/Decode.cs @@ -41,7 +41,7 @@ using DiscImageChef.Decoders.ATA; using DiscImageChef.Decoders.CD; using DiscImageChef.Decoders.SCSI; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class DecodeCommand : Command { @@ -87,8 +87,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, bool sectorTags, - ulong startSector) + public static int Invoke(bool verbose, bool debug, bool diskTags, string imagePath, string length, + bool sectorTags, ulong startSector) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Entropy.cs b/DiscImageChef/Commands/Image/Entropy.cs similarity index 97% rename from DiscImageChef/Commands/Entropy.cs rename to DiscImageChef/Commands/Image/Entropy.cs index 245fa180b..248532b8f 100644 --- a/DiscImageChef/Commands/Entropy.cs +++ b/DiscImageChef/Commands/Image/Entropy.cs @@ -38,7 +38,7 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Console; using DiscImageChef.Core; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class EntropyCommand : Command { @@ -76,8 +76,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool debug, bool verbose, bool duplicatedSectors, string imagePath, bool separatedTracks, - bool wholeDisc) + public static int Invoke(bool debug, bool verbose, bool duplicatedSectors, string imagePath, + bool separatedTracks, bool wholeDisc) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Image/ImageFamily.cs b/DiscImageChef/Commands/Image/ImageFamily.cs new file mode 100644 index 000000000..38d406714 --- /dev/null +++ b/DiscImageChef/Commands/Image/ImageFamily.cs @@ -0,0 +1,55 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : ImageFamily.cs +// Author(s) : Natalia Portillo +// +// Component : Verbs. +// +// --[ Description ] ---------------------------------------------------------- +// +// Implements the 'image' verb. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.CommandLine; + +namespace DiscImageChef.Commands.Image +{ + public class ImageFamily : Command + { + public ImageFamily() : base("image", "Commands to manage images") + { + AddAlias("i"); + + AddCommand(new AnalyzeCommand()); + AddCommand(new ChecksumCommand()); + AddCommand(new CompareCommand()); + AddCommand(new ConvertImageCommand()); + AddCommand(new CreateSidecarCommand()); + AddCommand(new DecodeCommand()); + AddCommand(new EntropyCommand()); + AddCommand(new ImageInfoCommand()); + AddCommand(new PrintHexCommand()); + AddCommand(new VerifyCommand()); + } + } +} \ No newline at end of file diff --git a/DiscImageChef/Commands/ImageInfo.cs b/DiscImageChef/Commands/Image/ImageInfo.cs similarity index 99% rename from DiscImageChef/Commands/ImageInfo.cs rename to DiscImageChef/Commands/Image/ImageInfo.cs index 2e046cdea..b70b980e6 100644 --- a/DiscImageChef/Commands/ImageInfo.cs +++ b/DiscImageChef/Commands/Image/ImageInfo.cs @@ -39,7 +39,7 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Console; using DiscImageChef.Core; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class ImageInfoCommand : Command { diff --git a/DiscImageChef/Commands/PrintHex.cs b/DiscImageChef/Commands/Image/PrintHex.cs similarity index 97% rename from DiscImageChef/Commands/PrintHex.cs rename to DiscImageChef/Commands/Image/PrintHex.cs index ca1f88b03..15d83447b 100644 --- a/DiscImageChef/Commands/PrintHex.cs +++ b/DiscImageChef/Commands/Image/PrintHex.cs @@ -38,7 +38,7 @@ using DiscImageChef.CommonTypes.Interfaces; using DiscImageChef.Console; using DiscImageChef.Core; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class PrintHexCommand : Command { @@ -84,8 +84,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool debug, bool verbose, string imagePath, ulong length, bool longSectors, ulong startSector, - ushort widthBytes) + public static int Invoke(bool debug, bool verbose, string imagePath, ulong length, bool longSectors, + ulong startSector, ushort widthBytes) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/Verify.cs b/DiscImageChef/Commands/Image/Verify.cs similarity index 98% rename from DiscImageChef/Commands/Verify.cs rename to DiscImageChef/Commands/Image/Verify.cs index 47c32b076..49cf3fffc 100644 --- a/DiscImageChef/Commands/Verify.cs +++ b/DiscImageChef/Commands/Image/Verify.cs @@ -41,7 +41,7 @@ using DiscImageChef.CommonTypes.Structs; using DiscImageChef.Console; using DiscImageChef.Core; -namespace DiscImageChef.Commands +namespace DiscImageChef.Commands.Image { internal class VerifyCommand : Command { @@ -71,7 +71,8 @@ namespace DiscImageChef.Commands Handler = CommandHandler.Create(GetType().GetMethod(nameof(Invoke))); } - public static int Invoke(bool debug, bool verbose, string imagePath, bool verifyDisc = true, bool verifySectors = true) + public static int Invoke(bool debug, bool verbose, string imagePath, bool verifyDisc = true, + bool verifySectors = true) { MainClass.PrintCopyright(); diff --git a/DiscImageChef/Commands/DumpMedia.cs b/DiscImageChef/Commands/Media/DumpMedia.cs similarity index 99% rename from DiscImageChef/Commands/DumpMedia.cs rename to DiscImageChef/Commands/Media/DumpMedia.cs index 1f1c49633..4d8f20279 100644 --- a/DiscImageChef/Commands/DumpMedia.cs +++ b/DiscImageChef/Commands/Media/DumpMedia.cs @@ -275,11 +275,11 @@ namespace DiscImageChef.Commands char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + Devices.Device dev; try { - dev = new Device(devicePath); + dev = new Devices.Device(devicePath); if(dev.IsRemote) Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem, diff --git a/DiscImageChef/Commands/Media/MediaFamily.cs b/DiscImageChef/Commands/Media/MediaFamily.cs new file mode 100644 index 000000000..93815100c --- /dev/null +++ b/DiscImageChef/Commands/Media/MediaFamily.cs @@ -0,0 +1,48 @@ +// /*************************************************************************** +// The Disc Image Chef +// ---------------------------------------------------------------------------- +// +// Filename : MediaFamily.cs +// Author(s) : Natalia Portillo +// +// Component : Verbs. +// +// --[ Description ] ---------------------------------------------------------- +// +// Implements the 'media' verb. +// +// --[ 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 . +// +// ---------------------------------------------------------------------------- +// Copyright © 2011-2019 Natalia Portillo +// ****************************************************************************/ + +using System.CommandLine; + +namespace DiscImageChef.Commands.Media +{ + public class MediaFamily : Command + { + public MediaFamily() : base("media", "Commands to manage media inserted in devices") + { + AddAlias("m"); + + AddCommand(new DumpMediaCommand()); + AddCommand(new MediaInfoCommand()); + AddCommand(new MediaScanCommand()); + } + } +} \ No newline at end of file diff --git a/DiscImageChef/Commands/MediaInfo.cs b/DiscImageChef/Commands/Media/MediaInfo.cs similarity index 99% rename from DiscImageChef/Commands/MediaInfo.cs rename to DiscImageChef/Commands/Media/MediaInfo.cs index d91a76a08..bcb9fa4b8 100644 --- a/DiscImageChef/Commands/MediaInfo.cs +++ b/DiscImageChef/Commands/Media/MediaInfo.cs @@ -55,7 +55,6 @@ using BCA = DiscImageChef.Decoders.Bluray.BCA; using Cartridge = DiscImageChef.Decoders.DVD.Cartridge; using Command = System.CommandLine.Command; using DDS = DiscImageChef.Decoders.DVD.DDS; -using Device = DiscImageChef.Devices.Device; using DMI = DiscImageChef.Decoders.Xbox.DMI; using Session = DiscImageChef.Decoders.CD.Session; using Spare = DiscImageChef.Decoders.DVD.Spare; @@ -105,11 +104,11 @@ namespace DiscImageChef.Commands char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + Devices.Device dev; try { - dev = new Device(devicePath); + dev = new Devices.Device(devicePath); if(dev.IsRemote) Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem, @@ -159,12 +158,12 @@ namespace DiscImageChef.Commands static void DoAtaMediaInfo() => DicConsole.ErrorWriteLine("Please use device-info command for ATA devices."); - static void DoNvmeMediaInfo(string outputPrefix, Device dev) => + static void DoNvmeMediaInfo(string outputPrefix, Devices.Device dev) => throw new NotImplementedException("NVMe devices not yet supported."); static void DoSdMediaInfo() => DicConsole.ErrorWriteLine("Please use device-info command for MMC/SD devices."); - static void DoScsiMediaInfo(bool debug, bool verbose, string outputPrefix, Device dev) + static void DoScsiMediaInfo(bool debug, bool verbose, string outputPrefix, Devices.Device dev) { var scsiInfo = new ScsiInfo(dev); diff --git a/DiscImageChef/Commands/MediaScan.cs b/DiscImageChef/Commands/Media/MediaScan.cs similarity index 98% rename from DiscImageChef/Commands/MediaScan.cs rename to DiscImageChef/Commands/Media/MediaScan.cs index 048d2fa45..a5670ffd1 100644 --- a/DiscImageChef/Commands/MediaScan.cs +++ b/DiscImageChef/Commands/Media/MediaScan.cs @@ -92,11 +92,11 @@ namespace DiscImageChef.Commands char.IsLetter(devicePath[0])) devicePath = "\\\\.\\" + char.ToUpper(devicePath[0]) + ':'; - Device dev; + Devices.Device dev; try { - dev = new Device(devicePath); + dev = new Devices.Device(devicePath); if(dev.IsRemote) Statistics.AddRemote(dev.RemoteApplication, dev.RemoteVersion, dev.RemoteOperatingSystem, diff --git a/DiscImageChef/DiscImageChef.csproj b/DiscImageChef/DiscImageChef.csproj index 38fc64a6c..c8321bc5a 100644 --- a/DiscImageChef/DiscImageChef.csproj +++ b/DiscImageChef/DiscImageChef.csproj @@ -53,36 +53,41 @@ - - - - - - - + + + + + + + + + + + - - - - - - - - - + + + + + + + + + + + + + + + + + + False - - - - - - - - diff --git a/DiscImageChef/Main.cs b/DiscImageChef/Main.cs index 3b9691aec..dcfcbeb2a 100644 --- a/DiscImageChef/Main.cs +++ b/DiscImageChef/Main.cs @@ -39,6 +39,10 @@ using System.Reflection; using System.Text; using System.Threading.Tasks; using DiscImageChef.Commands; +using DiscImageChef.Commands.Device; +using DiscImageChef.Commands.Filesystem; +using DiscImageChef.Commands.Image; +using DiscImageChef.Commands.Media; using DiscImageChef.Console; using DiscImageChef.Core; using DiscImageChef.Database; @@ -138,32 +142,17 @@ namespace DiscImageChef rootCommand.Description = $"{_assemblyTitle} {_assemblyVersion?.InformationalVersion}\n{_assemblyCopyright}"; - rootCommand.AddCommand(new AnalyzeCommand()); + rootCommand.AddCommand(new DatabaseFamily(masterDbUpdate)); + rootCommand.AddCommand(new DeviceFamily()); + rootCommand.AddCommand(new FilesystemFamily()); + rootCommand.AddCommand(new ImageFamily()); + rootCommand.AddCommand(new MediaFamily()); + rootCommand.AddCommand(new BenchmarkCommand()); - rootCommand.AddCommand(new ChecksumCommand()); - rootCommand.AddCommand(new CompareCommand()); rootCommand.AddCommand(new ConfigureCommand(false, false)); - rootCommand.AddCommand(new ConvertImageCommand()); - rootCommand.AddCommand(new CreateSidecarCommand()); - rootCommand.AddCommand(new DecodeCommand()); - rootCommand.AddCommand(new DeviceInfoCommand()); - rootCommand.AddCommand(new DeviceReportCommand()); - rootCommand.AddCommand(new DumpMediaCommand()); - rootCommand.AddCommand(new EntropyCommand()); - rootCommand.AddCommand(new ExtractFilesCommand()); rootCommand.AddCommand(new FormatsCommand()); - rootCommand.AddCommand(new ImageInfoCommand()); - rootCommand.AddCommand(new ListDevicesCommand()); rootCommand.AddCommand(new ListEncodingsCommand()); rootCommand.AddCommand(new ListNamespacesCommand()); - rootCommand.AddCommand(new ListOptionsCommand()); - rootCommand.AddCommand(new LsCommand()); - rootCommand.AddCommand(new MediaInfoCommand()); - rootCommand.AddCommand(new MediaScanCommand()); - rootCommand.AddCommand(new PrintHexCommand()); - rootCommand.AddCommand(new StatisticsCommand()); - rootCommand.AddCommand(new UpdateCommand(masterDbUpdate)); - rootCommand.AddCommand(new VerifyCommand()); rootCommand.AddCommand(new RemoteCommand()); return rootCommand.Invoke(args);