2014-04-17 19:58:14 +00:00
|
|
|
/***************************************************************************
|
2014-06-15 23:39:34 +01:00
|
|
|
The Disc Image Chef
|
2014-04-17 19:58:14 +00:00
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Filename : Main.cs
|
|
|
|
|
Version : 1.0
|
|
|
|
|
Author(s) : Natalia Portillo
|
|
|
|
|
|
|
|
|
|
Component : Main program loop.
|
|
|
|
|
|
|
|
|
|
Revision : $Revision$
|
|
|
|
|
Last change by : $Author$
|
|
|
|
|
Date : $Date$
|
|
|
|
|
|
|
|
|
|
--[ Description ] ----------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
Contains the main program loop.
|
|
|
|
|
|
|
|
|
|
--[ License ] --------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
2014-04-19 18:23:00 +01:00
|
|
|
it under the terms of the GNU General Public License as
|
2014-04-17 19:58:14 +00:00
|
|
|
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
|
2014-04-19 18:23:00 +01:00
|
|
|
GNU General Public License for more details.
|
2014-04-17 19:58:14 +00:00
|
|
|
|
2014-04-19 18:23:00 +01:00
|
|
|
You should have received a copy of the GNU General Public License
|
2014-04-17 19:58:14 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
----------------------------------------------------------------------------
|
|
|
|
|
Copyright (C) 2011-2014 Claunia.com
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
//$Id$
|
|
|
|
|
|
2011-03-03 18:34:33 +00:00
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2014-06-15 23:39:34 +01:00
|
|
|
using DiscImageChef.ImagePlugins;
|
|
|
|
|
using DiscImageChef.PartPlugins;
|
|
|
|
|
using DiscImageChef.Plugins;
|
2014-06-16 00:41:47 +01:00
|
|
|
using System.Reflection;
|
2011-03-03 18:34:33 +00:00
|
|
|
|
2014-06-15 23:39:34 +01:00
|
|
|
namespace DiscImageChef
|
2011-03-03 18:34:33 +00:00
|
|
|
{
|
2014-04-14 02:29:13 +00:00
|
|
|
class MainClass
|
|
|
|
|
{
|
2014-06-16 01:45:04 +01:00
|
|
|
|
2014-04-14 02:29:13 +00:00
|
|
|
public static bool isDebug;
|
2014-06-16 00:41:47 +01:00
|
|
|
public static bool isVerbose;
|
2014-04-14 02:29:13 +00:00
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
{
|
2014-06-16 00:41:47 +01:00
|
|
|
string invokedVerb = "";
|
|
|
|
|
object invokedVerbInstance = null;
|
|
|
|
|
|
|
|
|
|
var options = new Options();
|
|
|
|
|
if (!CommandLine.Parser.Default.ParseArguments(args, options,
|
|
|
|
|
(verb, subOptions) =>
|
|
|
|
|
{
|
|
|
|
|
// if parsing succeeds the verb name and correct instance
|
|
|
|
|
// will be passed to onVerbCommand delegate (string,object)
|
|
|
|
|
invokedVerb = verb;
|
|
|
|
|
invokedVerbInstance = subOptions;
|
|
|
|
|
}))
|
|
|
|
|
{
|
|
|
|
|
Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object[] attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
|
|
|
|
|
string AssemblyTitle = ((AssemblyTitleAttribute) attributes[0]).Title;
|
|
|
|
|
attributes = typeof(MainClass).Assembly.GetCustomAttributes(typeof(AssemblyCopyrightAttribute), false);
|
|
|
|
|
Version AssemblyVersion = typeof(MainClass).Assembly.GetName().Version;
|
|
|
|
|
string AssemblyCopyright = ((AssemblyCopyrightAttribute) attributes[0]).Copyright;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("{0} {1}", AssemblyTitle, AssemblyVersion);
|
|
|
|
|
Console.WriteLine("{0}", AssemblyCopyright);
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
|
|
|
|
|
switch (invokedVerb)
|
|
|
|
|
{
|
|
|
|
|
case "analyze":
|
|
|
|
|
AnalyzeSubOptions AnalyzeOptions = (AnalyzeSubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = AnalyzeOptions.Debug;
|
|
|
|
|
isVerbose = AnalyzeOptions.Verbose;
|
2014-06-16 01:45:04 +01:00
|
|
|
Commands.Analyze.doAnalyze(AnalyzeOptions);
|
2014-06-16 00:41:47 +01:00
|
|
|
break;
|
|
|
|
|
case "compare":
|
|
|
|
|
CompareSubOptions CompareOptions = (CompareSubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = CompareOptions.Debug;
|
|
|
|
|
isVerbose = CompareOptions.Verbose;
|
2014-06-16 01:45:04 +01:00
|
|
|
Commands.Compare.doCompare(CompareOptions);
|
2014-06-16 00:41:47 +01:00
|
|
|
break;
|
|
|
|
|
case "checksum":
|
|
|
|
|
ChecksumSubOptions ChecksumOptions = (ChecksumSubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = ChecksumOptions.Debug;
|
|
|
|
|
isVerbose = ChecksumOptions.Verbose;
|
2014-06-16 01:45:04 +01:00
|
|
|
Commands.Checksum.doChecksum(ChecksumOptions);
|
2014-06-16 00:41:47 +01:00
|
|
|
break;
|
|
|
|
|
case "verify":
|
|
|
|
|
VerifySubOptions VerifyOptions = (VerifySubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = VerifyOptions.Debug;
|
|
|
|
|
isVerbose = VerifyOptions.Verbose;
|
2014-06-16 01:45:04 +01:00
|
|
|
Commands.Verify.doVerify(VerifyOptions);
|
2014-06-16 00:41:47 +01:00
|
|
|
break;
|
2014-08-28 19:27:16 +01:00
|
|
|
case "printhex":
|
|
|
|
|
PrintHexSubOptions PrintHexOptions = (PrintHexSubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = PrintHexOptions.Debug;
|
|
|
|
|
isVerbose = PrintHexOptions.Verbose;
|
|
|
|
|
Commands.PrintHex.doPrintHex(PrintHexOptions);
|
|
|
|
|
break;
|
2014-09-01 03:44:39 +01:00
|
|
|
case "decode":
|
|
|
|
|
DecodeSubOptions DecodeOptions = (DecodeSubOptions)invokedVerbInstance;
|
|
|
|
|
isDebug = DecodeOptions.Debug;
|
|
|
|
|
isVerbose = DecodeOptions.Verbose;
|
|
|
|
|
Commands.Decode.doDecode(DecodeOptions);
|
|
|
|
|
break;
|
2014-06-16 00:41:47 +01:00
|
|
|
case "formats":
|
2014-06-16 01:50:49 +01:00
|
|
|
FormatsSubOptions FormatsOptions = (FormatsSubOptions)invokedVerbInstance;
|
|
|
|
|
isVerbose = FormatsOptions.Verbose;
|
2014-07-03 18:32:58 +01:00
|
|
|
isDebug = FormatsOptions.Debug;
|
2014-06-16 01:45:04 +01:00
|
|
|
Commands.Formats.ListFormats();
|
2014-06-16 00:41:47 +01:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
throw new ArgumentException("Should never arrive here!");
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-04-14 02:29:13 +00:00
|
|
|
}
|
2011-03-03 18:34:33 +00:00
|
|
|
}
|
|
|
|
|
|