public void TestHelp()
        {
            var helpText = CommandSerializer <HelpTest> .GetHelp();

            TestContext.Out.WriteLine(helpText);
            System.Diagnostics.Debug.WriteLine(helpText);
            Assert.IsNotEmpty(helpText);
            Assert.IsTrue(helpText.StartsWith("Usage"));
        }
示例#2
0
        static void Main(string[] args)
        {
            try
            {
                var options = CommandSerializer <CommandArgs> .Parse(args);

                options.Validate();

                try
                {
                    var parser = new ConsoleParser();
                    parser.Init(options.Countries);
                    var listOption     = options.Recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
                    var files          = (from file in Directory.EnumerateFiles(options.Input, "*.*", listOption) select file).ToList();
                    var remainingFiles = parser.Filter(files);

                    if (options.Help)
                    {
                        Console.Out.WriteLine(CommandSerializer <CommandArgs> .GetHelp(Console.WindowWidth));
                    }
                    else if (options.Stats)
                    {
                        Console.Out.WriteLine(options.GetSummary(files, remainingFiles));
                    }
                    else
                    {
                        Copy(remainingFiles, options);
                    }
                }
                catch (Exception ex)
                {
                    Console.Out.WriteLine(ex);
                }
            }
            catch (Exception)
            {
                Console.Out.WriteLine(CommandSerializer <CommandArgs> .GetHelp(Console.WindowWidth));
            }
        }