AddOptions() public method

Adds a text block with options usage informations.
Thrown when parameter is null.
public AddOptions ( object options ) : void
options object The instance that collected command line arguments parsed with class.
return void
Ejemplo n.º 1
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;
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
0
 public string GetUsage()
 {
   HelpText help = new HelpText(@"Machine.Migrations");
   help.Copyright = new CopyrightInfo("Machine Project", 2007, 2008, 2009);
   help.AddOptions(this);
   return help;
 }
Ejemplo n.º 4
0
        private static void Main(string[] args)
        {
            try
            {
                var options = new Options();
                if (!Parser.Default.ParseArguments(args, options))
                {
                    var helpText = new HelpText("Laan SolutionConverter", Assembly.GetEntryAssembly().GetName().Version.ToString());

                    helpText.AddOptions(options);
                    Console.WriteLine(helpText.ToString());
                    return;
                }

                switch (options.Mode)
                {
                    case Mode.Xml:
                        ConvertToXml(options);
                        break;

                    case Mode.Sln:
                        ConvertToSln(options);
                        break;
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }
Ejemplo n.º 5
0
        public string GetUsage()
        {
            var help = new HelpText
            {
                Heading = new HeadingInfo("#b#Versionr## #q#- the less hateful version control system.##"),
                AddDashesToOption = true,
            };
            help.FormatOptionHelpText += Help_FormatOptionHelpText;

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

                if (!string.IsNullOrEmpty(errors))
                {
                    help.AddPreOptionsLine(string.Concat(Environment.NewLine, "Invalid command:"));
                    help.AddPreOptionsLine(errors);
                }
            }
            help.AddPreOptionsLine(string.Format("\nUsage:\n   {0}\n", Usage));
            help.AddPreOptionsLine(string.Format("##The `#b#{0}##` Command:", Verb));
            foreach (var x in Description)
                help.AddPreOptionsLine("  " + x);
            help.AddPreOptionsLine("\n##Options:#b#");
            help.AddOptions(this);
            return help;
        }
Ejemplo n.º 6
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;
        }
        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;
        }
Ejemplo n.º 8
0
 public string GetUsage()
 {
   var help = new HelpText("Machine Javascript Bundler");
   help.AddPreOptionsLine(@"Example: jsbundler -b path\to\scripts path\to\scripts\folder1 path\to\scripts\folder2 \path\to\scripts\folder3");
   help.AddOptions(this);
   return help;
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
 public string GetUsage()
 {
     var help = new HelpText(desc);
     help.AdditionalNewLineAfterOption = true;
     help.AddOptions(this);
     return help;
 }
        public string GetUsage()
        {
            var help = new HelpText(new HeadingInfo("BottomShelf Host", Assembly.GetExecutingAssembly().GetName().Version.ToString(2)));
            help.Copyright = new CopyrightInfo("Peasant Coder Foundation", DateTime.Now.Year);
            help.AddOptions(this);

            return help.ToString();
        }
Ejemplo n.º 12
0
		public string GetUsage() {
			HelpText help = new HelpText(eMailServer.HeadingInfo);
			help.AdditionalNewLineAfterOption = true;
			help.Copyright = new CopyrightInfo("Ringo Leese", 2013, 2013);
			help.AddOptions(this);
				
			return help;
		}
Ejemplo n.º 13
0
		public string GetUsage() {
			HelpText help = new HelpText();
			help.AdditionalNewLineAfterOption = true;
			//help.Copyright = new CopyrightInfo("locrmap", 2009, 2012);
			help.AddOptions(this);
			
			return help;
		}
Ejemplo n.º 14
0
		public string GetUsage()
		{
			var help = new HelpText { AdditionalNewLineAfterOption = true };
			var execName = Assembly.GetExecutingAssembly().GetName().Name + ".exe";
			help.AddPreOptionsLine(string.Format("Usage: {0} -c {{command}} -a http://admin:[email protected]:5984/yourdb [-d .\\designDocuments] [-u user1 -p passw0rd]", execName));
			help.AddOptions(this);
			return help;
		}
Ejemplo n.º 15
0
 public string GetUsage()
 {
     var help = new HelpText("Windows S3 Uploader");
       help.Copyright = new CopyrightInfo("Palomino Labs, Inc.", 2012);
       help.AddPreOptionsLine("Command options:");
       help.AddOptions(this);
       help.AddPostOptionsLine("Omit accessKey and secretKey to get credentials from IAM");
       return help;
 }
Ejemplo n.º 16
0
 public string GetHelp()
 {
     var help = new HelpText("  Benutzung: xpatch xmlDatei xpath-Ausdruck [neuerwert] [parameter]"
                             + "\n\nWird kein neuer Wert angegeben, fordert xpatch zur "
                             + "Eingabe des gewünschten Wertes auf."
                             + "\n\nWeitere Parameter:");
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 17
0
        public string GetUsage()
        {
            var help = new HelpText
                {

                };
            help.AddOptions(this);
            return help;
        }
Ejemplo n.º 18
0
        public string GetUsage()
        {
            var help = new HelpText(_headingInfo);

            help.AdditionalNewLineAfterOption = true;
            help.AddPreOptionsLine(Assembly.GetExecutingAssembly().GetResourceText("qcat.usage.txt"));
            help.AddOptions(this);
            return help;
        }
Ejemplo n.º 19
0
        public string GetUsage()
        {
            HelpText text = new HelpText(" ");

            text.AddPreOptionsLine("  Usage: SlimNet.ConsoleHost.exe -p14000 -a\"C:\\path\\to\\assemblies\\\"");
            text.AddOptions(this);

            return text.ToString();
        }
Ejemplo n.º 20
0
        public string GetUsage()
        {
            var help = new HelpText("Usage Instructions:");
            help.AdditionalNewLineAfterOption = true;
            help.AddPreOptionsLine("This is free, open source software under the the MIT License <http://www.opensource.org/licenses/mit-license.php>.");
            help.AddOptions(this);

            return help;
        }
Ejemplo n.º 21
0
 public string GetUsage()
 {
     var help = new HelpText {
         AddDashesToOption = true,
         Heading = "Usage: AccuracyExperiment [OPTIONS]",
     };
     help.AddPostOptionsLine("詳しくは ReadMe.md を参照.\n");
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 22
0
 public string GetUsage()
 {
     var help = new HelpText {
         AddDashesToOption = true,
         Heading = "Usage: GeneralizedMaximumFlow [OPTIONS]",
     };
     help.AddPostOptionsLine("詳しくは ReadMe.md を参照.\n");
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 23
0
        public string GetUsage()
        {
            var helpText = new HelpText("Giles Options")
                               {
                                   AdditionalNewLineAfterOption = true
                               };
            helpText.AddOptions(this);

            return helpText;
        }
Ejemplo n.º 24
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();
 }
Ejemplo n.º 25
0
        public string GetUsage()
        {
            Version version = Assembly.GetExecutingAssembly().GetName().Version;
            var heading = new HeadingInfo(ApplicationName, version.Major + "." + version.Minor);

            var help = new HelpText(heading);
            help.Copyright = new CopyrightInfo(true, "Lars Corneliussen, Faktum Software GmbH", 2010);
            help.AddOptions(this);
            return help;
        }
Ejemplo n.º 26
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 27
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = "gRPC C# performance testing worker",
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("Usage:");
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 28
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = new HeadingInfo(".Net CPU Analyzer"),
         AdditionalNewLineAfterOption = true,
         AddDashesToOption = true
     };
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 29
0
 public string GetUsage()
 {
     var help = new HelpText
     {
         Heading = "gRPC C# interop testing server",
         AddDashesToOption = true
     };
     help.AddPreOptionsLine("Usage:");
     help.AddOptions(this);
     return help;
 }
Ejemplo n.º 30
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;
            }
Ejemplo n.º 31
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='options'>The instance that collected command line arguments parsed with <see cref="Parser"/> class.</param>
        /// <param name='onError'>A delegate used to customize the text block for reporting parsing errors.</param>
        /// <param name="verbsIndex">If true the output style is consistent with verb commands (no dashes), otherwise it outputs options.</param>
        public static HelpText AutoBuild(object options, Action <HelpText> onError, bool verbsIndex = false)
        {
            var auto = new HelpText
            {
                Heading   = HeadingInfo.Default,
                Copyright = CopyrightInfo.Default,
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = !verbsIndex
            };

            if (onError != null)
            {
                var list = ReflectionHelper.RetrievePropertyList <ParserStateAttribute>(options);
                if (list != null)
                {
                    onError(auto);
                }
            }

            var license = ReflectionHelper.GetAttribute <AssemblyLicenseAttribute>();

            if (license != null)
            {
                license.AddToHelpText(auto, true);
            }

            var usage = ReflectionHelper.GetAttribute <AssemblyUsageAttribute>();

            if (usage != null)
            {
                usage.AddToHelpText(auto, true);
            }

            auto.AddOptions(options);

            return(auto);
        }
Ejemplo 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>
        /// <param name="maxDisplayWidth">The maximum width of the display.</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,
            int maxDisplayWidth = DefaultMaximumLength)
        {
            var auto = new HelpText
            {
                Heading   = HeadingInfo.Empty,
                Copyright = CopyrightInfo.Empty,
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = !verbsIndex,
                MaximumDisplayWidth          = maxDisplayWidth
            };

            try
            {
                auto.Heading   = HeadingInfo.Default;
                auto.Copyright = CopyrightInfo.Default;
            }
            catch (Exception)
            {
                auto = onError(auto);
            }

            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);
        }