コード例 #1
0
ファイル: Program.cs プロジェクト: AerisG222/SizePhotos
        static void ShowUsage(IList<string> errors = null)
        {
            var help = new HelpText();

            help.Heading = "SizePhotos";
            help.AddPreOptionsLine("A tool to prepare and optimize images for display on the web.");

            // this is a little lame, but force a NotParsed<T> options result
            // so that we can get a nice help screen.  this might be required
            // if the passed args are valid to the parser, but not w/ custom
            // validation logic that runs after parsing
            var parser = new Parser(config => config.HelpWriter = null);
            var result = parser.ParseArguments<SizePhotoOptions>(new string[] { "--xxx" });
            help.AddOptions(result);

            if(errors != null)
            {
                help.AddPostOptionsLine("Errors:");
                help.AddPostOptionsLines(errors);
            }

            Console.WriteLine(help.ToString());
        }