예제 #1
0
        public static void Main(string[] args)
        {
            CompressionMethod.Load();
            ConversionMethod.Load();
            ArchiveMethod.Load();

            Console.ForegroundColor = ConsoleColor.White;

            Command root = new CommandRouter("", new Command[] {
                new CompressCommand(),
                new ConvertCommand(),
                new PackCommand()
            });

            if (args.Length > 0)
            {
                root.Execute(args);
                return;
            }

            while (true)
            {
                Console.Write("> ");
                string junk = Console.ReadLine();

                Stopwatch watch = new Stopwatch();

                watch.Start();
                try
                {
                    root.Execute(junk.Split(' '));
                }
                catch (CommandParseException ex)
                {
                    Console.WriteLine(ex.Message);
                }
                catch (Exception ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message);
                    Console.ForegroundColor = ConsoleColor.White;
                }

                watch.Stop();

                Console.WriteLine();
                Console.WriteLine("Command took " + watch.ElapsedMilliseconds + "ms to execute.");
            }
        }