AddPreOptionsLine() public method

Adds a text line after copyright and before options usage informations.
Thrown when parameter is null or empty string.
public AddPreOptionsLine ( string value ) : void
value string A instance.
return void
Exemplo n.º 1
0
        public string GetUsage()
        {
            var help = new HelpText
            {
                Copyright = new CopyrightInfo("MasterDevs", 2015),
                AdditionalNewLineAfterOption = false,
                AddDashesToOption = true,
            };
            help.AddPreOptionsLine("Usage: tidyJson [OPTIONS]");
            help.AddPreOptionsLine("Uses standard in and standard out if input or output not supplied");
            help.AddPostOptionsLine("Examples:");
            help.AddPostOptionsLine("    echo {json:'value'} | tidyJson");
            help.AddPostOptionsLine("        Read JSON from standard input and write it to standard output");
            help.AddPostOptionsLine(string.Empty);
            help.AddPostOptionsLine("    tidyJson -c");
            help.AddPostOptionsLine("        Read JSON from clipboard and write it back to the clipboard");
            help.AddPostOptionsLine(string.Empty);
            help.AddPostOptionsLine("    tidyJson -f myOutput.json");
            help.AddPostOptionsLine("        Read JSON from standard input and write it to the file myOutput.json");
            help.AddPostOptionsLine(string.Empty);
            help.AddPostOptionsLine("    tidyJson -i myInput.json");
            help.AddPostOptionsLine("        Read JSON from the file myInput.Json and write it to standard output");
            help.AddPostOptionsLine(string.Empty);
            help.AddPostOptionsLine("    tidyJson -i myInput.json -f myOutput.json");
            help.AddPostOptionsLine("        Read JSON from the file myInput.Json and write it to the file myOutput.json");

            help.AddOptions(this);
            return help;

            //return HelpText.AutoBuild(this,
            //  (HelpText current) => HelpText.DefaultParsingErrorsHandler(this, current));
        }
        public string GetUsage()
        {
            string processname = Process.GetCurrentProcess().ProcessName;

            var help = new HelpText
            {
                AdditionalNewLineAfterOption = false,
                AddDashesToOption = true,
                Copyright = new CopyrightInfo("Geoffrey Huntley <*****@*****.**>", DateTime.Now.Year),
                MaximumDisplayWidth = 160,
            };

            help.AddPreOptionsLine(Environment.NewLine);
            help.AddPreOptionsLine(
                String.Format(
                    "Usage: {0} --destination C:\\backups\\ --sleep 600 --instance https://yourinstance.atlassian.net --username admin --password password",
                    processname));

            help.AddOptions(this);

            if (LastParserState.Errors.Count <= 0) return help;

            string errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
            if (!string.IsNullOrEmpty(errors))
            {
                help.AddPostOptionsLine(Environment.NewLine);
                help.AddPostOptionsLine("ERROR(s):");help.AddPostOptionsLine(Environment.NewLine);
                help.AddPostOptionsLine(errors);
            }

            return help;
        }
Exemplo n.º 3
0
        public string GetUsage()
        {
            var help = new HelpText
            {
                Heading = new HeadingInfo("CqlSharp.Performance.Client", "0.1.0"),
                Copyright = new CopyrightInfo("Joost Reuzel", 2014),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = true
            };

            if(LastParserState.Errors.Any())
            {
                var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces

                if(!string.IsNullOrEmpty(errors))
                {
                    help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
                    help.AddPreOptionsLine(errors);
                }
            }

            help.AddPreOptionsLine("Usage: Client -c 100 -r 10000");
            help.AddOptions(this);
            return help;
        }
Exemplo n.º 4
0
        public string GetUsage()
        {
            var name = Assembly.GetExecutingAssembly().GetName();
            var help = new HelpText
            {
                Heading = new HeadingInfo(name.Name, name.Version.ToString()),
                Copyright = new CopyrightInfo("me!", 2015),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = true
            };

            if (LastParserState.Errors.Any())
            {
                var errors = help.RenderParsingErrorsText(this, 2);
                if (!string.IsNullOrEmpty(errors))
                {
                    help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
                    help.AddPreOptionsLine(errors);
                }
            }

            help.AddPreOptionsLine("Usage: RunMongoRun [options]");
            help.AddOptions(this);
            return help;
        }
Exemplo n.º 5
0
        public string GetUsage(string verb)
        {
            var help = new HelpText
            {
                Heading = HeadingInfo.Default,
                Copyright = CopyrightInfo.Default,
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = true
            };

            object optionsObject = null;
            if (verb == DotNetCommandName)
            {
                help.AddPreOptionsLine(Environment.NewLine + "Usage: ToTypeScriptD dotnet [--specialTypes] [File1.dll]...[FileN.dll]");
                optionsObject = new DotNetSubOptions();
            }
            else if (verb == WinmdCommandName)
            {
                help.AddPreOptionsLine(Environment.NewLine + "Usage: ToTypeScriptD winmd [--specialTypes] [File1.winmd]...[FileN.winmd]");
                optionsObject = new WinmdSubOptions();
            }

            if (optionsObject != null)
            {
                help.AddOptions(optionsObject); ;
            }
            else
            {
                help.AddDashesToOption = false;
                help.AddOptions(this);
            }

            return help;
        }
Exemplo n.º 6
0
 public string GetUsage()
 {
     var help = new HelpText("Usage:");
     help.AddPreOptionsLine("Ex: SharpMigrations -a MyAssembly.dll -m auto -v 10 -> Migrates to version 10 (no prompt)");
     help.AddPreOptionsLine("Ex: SharpMigrations -a MyAssembly.dll -m script -f script.sql -v 10 -> Generates scripts from current version to version 10 into script.sql file");
     help.AddPreOptionsLine("Ex: SharpMigrations -a MyAssembly.dll -m script -v 10 -g superplugin -> Generates scripts from current version to version 10 using migration group 'superplugin'");
     help.AddPreOptionsLine("Ex: SharpMigrations -a MyAssembly.dll -m seed -s myseed -> Run seed named myseed");
     help.AddOptions(this);
     return help.ToString();
 }
Exemplo n.º 7
0
 private void HandleParsingErrorsInHelp(HelpText help)
 {
     if (LastParserState != null && LastParserState.Errors.Any()) {
         var errors = help.RenderParsingErrorsText(this, 2);
         if (!string.IsNullOrEmpty(errors)) {
             help.AddPreOptionsLine(Environment.NewLine + "Error(s):");
             help.AddPreOptionsLine(errors);
         }
     }
 }
Exemplo n.º 8
0
            public string GetUsage()
            {
                var help = new HelpText(Program._headingInfo);
                
                help.AdditionalNewLineAfterOption = true;
                help.AddPreOptionsLine(string.Format(@"Usage: {0}", Assembly.GetExecutingAssembly().GetName().Name));
                help.AddPreOptionsLine(string.Format(@"       {0} -c 4 -d 24-3-2010 -t 10", Assembly.GetExecutingAssembly().GetName().Name));
                help.AddOptions(this);

                return help;
            }
Exemplo n.º 9
0
 public string GetUsage()
 {
     HelpText help = new HelpText(_headingInfo);
     help.Copyright = new CopyrightInfo("Adam Machanic", 2006);
     help.AddPreOptionsLine("Check for updates at: https://github.com/ErikEJ/SqlQueryStress");
     help.AddPreOptionsLine("");
     help.AddPreOptionsLine("Sample usage:");
     help.AddPreOptionsLine("SqlQueryStress -c \"saved.SqlStress\" -u  -t 32");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 10
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("");
     help.AddPreOptionsLine($"Usage: {AppDomain.CurrentDomain.FriendlyName} pluginDirectory [options]");
     help.AddOptions(this);
     return help;
 }
 public string GetUsage()
 {
     var help = new HelpText(new HeadingInfo("MyProgram", "1.0"));
     help.Copyright = new CopyrightInfo("Authors, Inc.", 2007);
     help.AddPreOptionsLine("This software is under the terms of the XYZ License");
     help.AddPreOptionsLine("(http://license-text.org/show.cgi?xyz).");
     help.AddPreOptionsLine("Usage: myprog --input equations-file.xml -o result-file.xml");
     help.AddPreOptionsLine("       myprog -i equations-file.xml --paralell");
     help.AddPreOptionsLine("       myprog -i equations-file.xml -vo result-file.xml");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 12
0
			public string GetUsage()
			{
				var help = new HelpText( Program._headingInfo );
				help.AdditionalNewLineAfterOption = true;
				help.Copyright = new CopyrightInfo( "Axiom Engine Team", 2003, 2010 );
				help.AddPreOptionsLine( "This is free software. You may redistribute copies of it under the terms of" );
				help.AddPreOptionsLine( "the LGPL License <http://www.opensource.org/licenses/lgpl-license.php>." );
				help.AddPreOptionsLine( "Usage: SampleApp -sCompositor " );
				help.AddOptions( this );

				return help;
			}
Exemplo n.º 13
0
 public string GetUsage()
 {
     var help = new HelpText {
         Heading = new HeadingInfo("BDInfoCli", (Assembly.GetExecutingAssembly().GetName().Version).ToString()),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("Licensed under LGPL V2.1");
     help.AddPreOptionsLine("Usage: BDInfoCli <BD Folder> <Save Path>");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 14
0
 private void HandleParsingErrorsInHelp(HelpText help)
 {
     if (this.LastPostParsingState.Errors.Count > 0)
     {
         var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
         if (!string.IsNullOrEmpty(errors))
         {
             help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
             help.AddPreOptionsLine(errors);
         }
     }
 }
Exemplo n.º 15
0
 public string GetUsage()
 {
     var help = new HelpText()
     {
         Heading = new HeadingInfo("Gullap | http://devtyr.com", Assembly.GetExecutingAssembly().GetName().Version.ToString()),
         Copyright = new CopyrightInfo("Norbert Eder", 2013),
         AddDashesToOption = true
     };
     help.AddPreOptionsLine(" ");
     help.AddPreOptionsLine("Usage: GullapConsole -option value");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 16
0
        public string GetUsage() {
            var help = new HelpText {
                Heading = $"Foundatio Job Runner v{Program.GetInformationalVersion()}",
                AdditionalNewLineAfterOption = false,
                AddDashesToOption = true
            };
            
            help.AddPreOptionsLine(" ");
            help.AddPreOptionsLine("Example usage: job -t \"MyAssembly.MyJobType, MyAssembly\" -c");
            help.AddOptions(this);

            return help;
        }
Exemplo n.º 17
0
 public static string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("IEsnapper", "1.0"),
         Copyright = new CopyrightInfo("Andy Oakley", 2012),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine(" ");
     help.AddPreOptionsLine("Usage: IEsnapper -u http://www.bing.com -o bing.png");
     help.AddOptions(options);
     return help;
 }
Exemplo n.º 18
0
        public string GetUsage()
        {
            // --------------------------------------------------
            // Initializes the HelpText object
            // --------------------------------------------------
            var help = new HelpText
            {
                AdditionalNewLineAfterOption = true,
                AddDashesToOption = true
            };

            help.AddPreOptionsLine(string.Format("  PNP.Deployer (v.{0}) - By Simon-Pierre Plante", Assembly.GetExecutingAssembly().GetName().Version.ToString()));
            help.AddPreOptionsLine("");
            help.AddPreOptionsLine("");

            // --------------------------------------------------
            // Adds the error section if any
            // --------------------------------------------------
            if (this.LastParserState != null && this.LastParserState.Errors.Count > 0 )
            {

                var errors = help.RenderParsingErrorsText(this, 4);

                if (!string.IsNullOrEmpty(errors))
                {
                    help.AddPreOptionsLine("  Error(s):");
                    help.AddPreOptionsLine("");
                    help.AddPreOptionsLine(errors);
                    help.AddPreOptionsLine("");
                }
            }

            // --------------------------------------------------
            // Adds the Usage section
            // --------------------------------------------------
            help.AddPreOptionsLine("  Usage:");
            help.AddPreOptionsLine("");
            help.AddPreOptionsLine("    PNP.Deployer.exe --WorkingDirectory \"C:\\DeploymentFolder\"");
            help.AddPreOptionsLine("                     [--PromptCredentials] [--Environment \"OnPrem|Online\"]");
            help.AddPreOptionsLine("");
            help.AddPreOptionsLine("");

            // --------------------------------------------------
            // Adds the Options section
            // --------------------------------------------------
            help.AddPreOptionsLine("  Options: ");
            help.AddOptions(this);

            return help;
        }
Exemplo n.º 19
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("TfsCompareBuildDefinitions", "1.0.0.0"),
         Copyright = new CopyrightInfo("Toolfactory", 2015),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("License: As is");
     help.AddPreOptionsLine("Usage: TfsCompareBuildDefinitions.exe -c http://logpmtfs01v:8080/tfs/Logitravel [options]");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 20
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("jstestcover", "1.0.0"),
         Copyright = new CopyrightInfo("Joe Doyle", 2013),
         AdditionalNewLineAfterOption = false,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine(" ");
     help.AddPreOptionsLine("Usage: jstestcover [options] [file|dir]");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 21
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("TfsCreateWebBuildDefinitions", "1.0.0.0"),
         Copyright = new CopyrightInfo("Toolfactory - Logitravel - 20 cool pillows :-)", 2015),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("License: free, as in free beer.");
     help.AddPreOptionsLine("Usage: TfsCreateWebBuildDefinitions.exe [options]");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 22
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("TfsUpdateBuildDefinitions", "1.0.0.0"),
         Copyright = new CopyrightInfo("Toolfactory", 2014),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("License: Free, as in free beer.");
     help.AddPreOptionsLine("Usage: TfsUpdateBuildDefinitions.exe [options]");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 23
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("\r\nParallel Execution Application", "1.0"),
         Copyright = new CopyrightInfo("Sean McAdams", 2014),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true,
     };
     help.AddPreOptionsLine("\r\nExample Usage: ParallelExecution.exe -u -f notepad.exe -r \"172.0.0.0\"");
     help.AddPreOptionsLine(    "        Usage: ParallelExecution.exe -s \"172.0.0.0\"");
     help.AddOptions(this);
     return help;
 }
        public String GetUsage()
        {
            var help = new HelpText(new HeadingInfo("MsBuilderific", "1.0.1").ToString()){
                MaximumDisplayWidth = Console.WindowWidth, 
                Copyright = new CopyrightInfo("Vooban Inc.", 2011)
            };

            help.AddPreOptionsLine("Usage : MsBuilderific.Console -r C:\\Sources -e C:\\Sources\\test.csproj;C:\\Sources\\Obsolete;");
            help.AddPreOptionsLine("");
            help.AddOptions(this);
            help.AddPostOptionsLine("\r\n"); 

            return help;
        }        
Exemplo n.º 25
0
 public string GetUsage()
 {
     var help = new HelpText()
     {
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("For details regarding Roku development, visit http://sdkdocs.roku.com/display/sdkdoc/Developer+Guide");
     help.AddPreOptionsLine("");
     help.AddPreOptionsLine("Usage:");
     help.AddPostOptionsLine("Example:   rokuloader -h 192.168.1.10 -p password -z c:\\rokudev\\package.zip");
     help.AddPostOptionsLine("");
     help.AddOptions(this);
     return help;
 }
        public string GetUsage()
        {
            var help = new HelpText(new HeadingInfo("low-level-sendkeys", "0.5b"));
            help.AdditionalNewLineAfterOption = true;
            help.Copyright = new CopyrightInfo("Teus", 2011);
            help.AddPreOptionsLine("This is free software. You may redistribute copies of it under the terms of");
            help.AddPreOptionsLine("the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
            help.AddPreOptionsLine("Usage: SampleApp -rMyData.in -wMyData.out --calculate");
            help.AddPreOptionsLine(string.Format("       SampleApp -rMyData.in -i -j{0} file0.def file1.def", 9.7));
            help.AddPreOptionsLine("       SampleApp -rMath.xml -wReport.bin -o *;/;+;-");
            help.AddOptions(this);

            return help;
        }
Exemplo n.º 27
0
 internal void AddToHelpText(HelpText helpText, bool before)
 {
     if (before)
     {
         if (!string.IsNullOrEmpty(_line1))
         {
             helpText.AddPreOptionsLine(_line1);
         }
         if (!string.IsNullOrEmpty(_line2))
         {
             helpText.AddPreOptionsLine(_line2);
         }
         if (!string.IsNullOrEmpty(_line3))
         {
             helpText.AddPreOptionsLine(_line3);
         }
         if (!string.IsNullOrEmpty(_line4))
         {
             helpText.AddPreOptionsLine(_line4);
         }
         if (!string.IsNullOrEmpty(_line5))
         {
             helpText.AddPreOptionsLine(_line5);
         }
     }
     else
     {
         if (!string.IsNullOrEmpty(_line1))
         {
             helpText.AddPostOptionsLine(_line1);
         }
         if (!string.IsNullOrEmpty(_line2))
         {
             helpText.AddPostOptionsLine(_line2);
         }
         if (!string.IsNullOrEmpty(_line3))
         {
             helpText.AddPostOptionsLine(_line3);
         }
         if (!string.IsNullOrEmpty(_line4))
         {
             helpText.AddPostOptionsLine(_line4);
         }
         if (!string.IsNullOrEmpty(_line5))
         {
             helpText.AddPostOptionsLine(_line5);
         }
     }
 }
        public string GetUsage()
        {
            var help = new HelpText(new HeadingInfo("Semantic Versioning", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()))
            {
                AdditionalNewLineAfterOption = false,
                MaximumDisplayWidth = Console.WindowWidth,
                Copyright = new CopyrightInfo("Endjin", DateTime.Now.Year)
            };

            help.AddPreOptionsLine("Usage:");
            help.AddPreOptionsLine(@"    Endjin.SemanticVersioning.TeamCity.exe -o <PATH>\foo.final.dll -p <PATH>\foo.dll -c <PATH>\foo.dll -v '2.0.0'");
            help.AddOptions(this);

            return help;
        } 
Exemplo n.º 29
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("GooDPal", "v0.0.0.1"),
         Copyright = new CopyrightInfo("<Vlachakis Dimitris>", 2015),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine(" ");
     help.AddPreOptionsLine("Usage: GooDPal -l Path/To/Dir/For/Sync");
     help.AddPreOptionsLine("       GooDPal -l Path/To/Dir/For/Sync -r Remote/Root/Path");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 30
0
        public string GetUsage()
        {
            var help = new HelpText(Constants.AppName);
            help.AdditionalNewLineAfterOption = true;
            help.Copyright = new CopyrightInfo("Chitza", 2012, 2012);
            this.HandleParsingErrorsInHelp(help);

            help.AddPreOptionsLine(@"Usage: " + Constants.AppName);
            help.AddPreOptionsLine(@"        -s Source.xml -m /xpath/to/nodes/to/select");
            help.AddPreOptionsLine(@"        -t Target.xml -n /xpath/to/insert/location");
            help.AddPreOptionsLine(@"        -o Output.xml");
            help.AddOptions(this);

            return help;
        }
Exemplo n.º 31
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo("TargetFramework", "1.0.0.0"),
         Copyright = new CopyrightInfo("Toolfactory", 2015),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("License: As is");
     help.AddPreOptionsLine("Usage: TargetFramework.exe --input <File|Dir> [--output <outputfile>] [--verbose]");
     help.AddPreOptionsLine(@"Example: TargetFramework.exe -i Toolfactory.Mail.dll -o Assemblies.txt --verbose");
     help.AddOptions(this);
     return help;
 }
Exemplo n.º 32
0
        /// <summary>
        /// Creates a new instance of the <see cref="CommandLine.Text.HelpText"/> class using common defaults.
        /// </summary>
        /// <returns>
        /// An instance of <see cref="CommandLine.Text.HelpText"/> class.
        /// </returns>
        /// <param name='parserResult'>The <see cref="CommandLine.ParserResult{T}"/> containing the instance that collected command line arguments parsed with <see cref="CommandLine.Parser"/> class.</param>
        /// <param name='onError'>A delegate used to customize the text block of reporting parsing errors text block.</param>
        /// <param name='onExample'>A delegate used to customize <see cref="CommandLine.Text.Example"/> model used to render text block of usage examples.</param>
        /// <param name="verbsIndex">If true the output style is consistent with verb commands (no dashes), otherwise it outputs options.</param>
        /// <remarks>The parameter <paramref name="verbsIndex"/> is not ontly a metter of formatting, it controls whether to handle verbs or options.</remarks>
        public static HelpText AutoBuild <T>(
            ParserResult <T> parserResult,
            Func <HelpText, HelpText> onError,
            Func <Example, Example> onExample,
            bool verbsIndex = false)
        {
            var auto = new HelpText
            {
                Heading   = HeadingInfo.Default,
                Copyright = CopyrightInfo.Default,
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = !verbsIndex
            };

            var errors = Enumerable.Empty <Error>();

            if (onError != null && parserResult.Tag == ParserResultType.NotParsed)
            {
                errors = ((NotParsed <T>)parserResult).Errors;

                if (errors.OnlyMeaningfulOnes().Any())
                {
                    auto = onError(auto);
                }
            }

            ReflectionHelper.GetAttribute <AssemblyLicenseAttribute>()
            .Do(license => license.AddToHelpText(auto, true));

            var usageAttr  = ReflectionHelper.GetAttribute <AssemblyUsageAttribute>();
            var usageLines = HelpText.RenderUsageTextAsLines(parserResult, onExample).ToMaybe();

            if (usageAttr.IsJust() || usageLines.IsJust())
            {
                var heading = auto.SentenceBuilder.UsageHeadingText();
                if (heading.Length > 0)
                {
                    auto.AddPreOptionsLine(heading);
                }
            }

            usageAttr.Do(
                usage => usage.AddToHelpText(auto, true));

            usageLines.Do(
                lines => auto.AddPreOptionsLines(lines));

            if ((verbsIndex && parserResult.TypeInfo.Choices.Any()) ||
                errors.Any(e => e.Tag == ErrorType.NoVerbSelectedError))
            {
                auto.AddDashesToOption = false;
                auto.AddVerbs(parserResult.TypeInfo.Choices.ToArray());
            }
            else
            {
                auto.AddOptions(parserResult);
            }

            return(auto);
        }
Exemplo n.º 33
0
        /// <summary>
        /// Supplies a default parsing error handler implementation.
        /// </summary>
        /// <param name='parserResult'>The <see cref="CommandLine.ParserResult{T}"/> containing the instance that collected command line arguments parsed with <see cref="CommandLine.Parser"/> class.</param>
        /// <param name="current">The <see cref="CommandLine.Text.HelpText"/> instance.</param>
        public static HelpText DefaultParsingErrorsHandler <T>(ParserResult <T> parserResult, HelpText current)
        {
            if (parserResult == null)
            {
                throw new ArgumentNullException("parserResult");
            }
            if (current == null)
            {
                throw new ArgumentNullException("current");
            }

            if (((NotParsed <T>)parserResult).Errors.OnlyMeaningfulOnes().Empty())
            {
                return(current);
            }

            var errors = RenderParsingErrorsTextAsLines(parserResult,
                                                        current.SentenceBuilder.FormatError,
                                                        current.SentenceBuilder.FormatMutuallyExclusiveSetErrors,
                                                        2); // indent with two spaces

            if (errors.Empty())
            {
                return(current);
            }

            return(current
                   .AddPreOptionsLine(
                       string.Concat(Environment.NewLine, current.SentenceBuilder.ErrorsHeadingText()))
                   .AddPreOptionsLines(errors));
        }
Exemplo n.º 34
0
 public static void DefaultParsingErrorsHandler(CommandLineOptionsBase options, HelpText current)
 {
     if (options.InternalLastPostParsingState.Errors.Count > 0)
     {
         var errors = current.RenderParsingErrorsText(options, 2); // indent with two spaces
         if (!string.IsNullOrEmpty(errors))
         {
             current.AddPreOptionsLine(string.Concat(Environment.NewLine, current.SentenceBuilder.ErrorsHeadingText));
             //current.AddPreOptionsLine(errors);
             var lines = errors.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
             foreach (var line in lines)
             {
                 current.AddPreOptionsLine(line);
             }
         }
     }
 }
Exemplo n.º 35
0
 internal HelpText AddToHelpText(HelpText helpText, bool before)
 {
     // before flag only distinguishes which action is called,
     // so refactor common code and call with appropriate func
     return(before
         ? this.AddToHelpText(helpText, line => helpText.AddPreOptionsLine(line))
         : this.AddToHelpText(helpText, line => helpText.AddPostOptionsLine(line)));
 }
Exemplo n.º 36
0
        /// <summary>
        /// Supplies a default parsing error handler implementation.
        /// </summary>
        /// <param name='parserResult'>The <see cref="CommandLine.ParserResult{T}"/> containing the instance that collected command line arguments parsed with <see cref="CommandLine.Parser"/> class.</param>
        /// <param name="current">The <see cref="CommandLine.Text.HelpText"/> instance.</param>
        public static HelpText DefaultParsingErrorsHandler <T>(ParserResult <T> parserResult, HelpText current)
        {
            if (parserResult == null)
            {
                throw new ArgumentNullException("parserResult");
            }
            if (current == null)
            {
                throw new ArgumentNullException("current");
            }

            if (FilterMeaningfulErrors(((NotParsed <T>)parserResult).Errors).Empty())
            {
                return(current);
            }

            var errors = RenderParsingErrorsText(parserResult,
                                                 current.SentenceBuilder.FormatError,
                                                 current.SentenceBuilder.FormatMutuallyExclusiveSetErrors,
                                                 2); // indent with two spaces

            if (string.IsNullOrEmpty(errors))
            {
                return(current);
            }

            current.AddPreOptionsLine(
                string.Concat(Environment.NewLine, current.SentenceBuilder.ErrorsHeadingText()));
            var lines = errors.Split(
                new[] { Environment.NewLine }, StringSplitOptions.None);

            lines.ForEach(
                line => current.AddPreOptionsLine(line));

            return(current);
        }