示例#1
0
        private static int RunCommand(CommandLineOptions options)
        {
            Console.WriteLine(GetHelpText());

            VerifierResult results = null;

            if (!string.IsNullOrWhiteSpace(options.File))
            {
                Console.WriteLine(options.File);

                results = TemplateJsonVerifier.VerifyTemplatePathAsync(options.File).Result;
            }
            else if (options.Directories.Any())
            {
                foreach (var directory in options.Directories)
                {
                    Console.WriteLine(directory);
                }

                results = TemplateFolderVerifier.VerifyTemplateFolders(!options.NoWarnings, options.Directories);
            }

            if (results != null)
            {
                foreach (var result in results.Messages)
                {
                    Console.WriteLine(result);
                }
            }

            return(0);
        }
示例#2
0
        public static void Main(string[] args)
        {
            Task.Run(async() =>
            {
                var options = new CommandLineOptions();

                if (args?.Any() != false && CommandLine.Parser.Default.ParseArguments(args, options))
                {
                    var appTitle = new HelpText
                    {
                        Heading   = HeadingInfo.Default,
                        Copyright = CopyrightInfo.Default,
                        AdditionalNewLineAfterOption = true,
                        AddDashesToOption            = true
                    };

                    Console.WriteLine(appTitle);

                    VerifierResult results = null;

                    if (!string.IsNullOrWhiteSpace(options.File))
                    {
                        Console.WriteLine(options.File);

                        results = await TemplateJsonVerifier.VerifyTemplatePathAsync(options.File);
                    }
                    else if (options.Directories.Any())
                    {
                        foreach (var directory in options.Directories)
                        {
                            Console.WriteLine(directory);
                        }

                        results = TemplateFolderVerifier.VerifyTemplateFolders(!options.NoWarnings, options.Directories);
                    }
                    else
                    {
                        Console.WriteLine(options.GetUsage());
                    }

                    if (results != null)
                    {
                        foreach (var result in results.Messages)
                        {
                            Console.WriteLine(result);
                        }
                    }
                }
                else
                {
                    Console.WriteLine(options.GetUsage());
                }
            }).Wait();

            Console.ReadKey(true);
        }