Ejemplo n.º 1
0
        static int Main(string[] args)
        {
            ICommandLine  commandLine = new CommandLine(args);
            ILogger       logger      = new RepackLogger();
            IFile         file        = new FileWrapper();
            RepackOptions options     = new RepackOptions(commandLine, logger, file);
            int           returnCode  = -1;

            try
            {
                if (options.ShouldShowUsage())
                {
                    Usage();
                    Exit(2);
                }
                options.Parse();

                //TODO: Open the Logger before the parse
                if (logger.Open(options.LogFile))
                {
                    options.Log             = true;
                    logger.ShouldLogVerbose = options.LogVerbose;
                }

                ILRepack repack = new ILRepack(options, logger);
                repack.Repack();
                returnCode = 0;
            }
            catch (RepackOptions.InvalidTargetKindException e)
            {
                Console.WriteLine(e.Message);
                Usage();
                Exit(2);
            }
            catch (Exception e)
            {
                logger.Log(e);
                returnCode = 1;
            }
            finally
            {
                logger.Close();
                if (options.PauseBeforeExit)
                {
                    Console.WriteLine("Press Any Key To Continue");
                    Console.ReadKey(true);
                }
            }
            return(returnCode);
        }