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); } }
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(); }
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(); }
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(); }
public string GenerateHelpMessage() { var help = new HelpText { AdditionalNewLineAfterOption = true, AddDashesToOption = true }; help.AddOptions(this); return help.ToString(); }
public string GetUsage() { var help = new HelpText { AddDashesToOption = true }; help.AddPreOptionsLine("pneumatictube -f <file> -p <path>"); help.AddOptions(this); return help.ToString(); }
public string GetUsage() { var asm = Assembly.GetExecutingAssembly(); var productName = asm.GetCustomAttributes(typeof (AssemblyTitleAttribute), false) .OfType<AssemblyTitleAttribute>() .Single() .Title; var productVersion = asm.GetCustomAttributes(typeof (AssemblyInformationalVersionAttribute), false) .OfType<AssemblyInformationalVersionAttribute>() .Single() .InformationalVersion; var productCopyright = asm.GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false) .OfType<AssemblyCopyrightAttribute>() .Single() .Copyright; var help = new HelpText { AddDashesToOption = true, AdditionalNewLineAfterOption = true, Copyright = productCopyright, Heading = new HeadingInfo(productName, productVersion), MaximumDisplayWidth = Console.BufferWidth }; var errors = help.RenderParsingErrorsText(this, 2); if (!string.IsNullOrEmpty(errors)) { help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):")); help.AddPreOptionsLine(errors); } help.AddPreOptionsLine(" "); #if !NO_COMMANDLINE help.AddPreOptionsLine(((AssemblyLicenseAttribute)assembly .GetCustomAttributes(typeof(AssemblyLicenseAttribute), false) .Single()).Value.Trim()); #else help.AddPreOptionsLine( "This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>."); #endif help.AddPreOptionsLine(" "); help.AddPreOptionsLine(string.Format("{0} [options...] \"<targetpath>\"", Process.GetCurrentProcess().ProcessName)); help.AddOptions(this); return help.ToString(); }
public void When_defined_MetaValue_should_be_rendered() { // Fixture setup // Exercize system var sut = new HelpText("Meta Value.") .AddOptions(new FakeOptionsWithMetaValue()); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); Assert.Equal("i FILE, input-file=FILE Required. Specify input FILE to be processed.", lines[2]); // Teardown }
public string GetUsage() { //ヘッダーの設定 HeadingInfo head = new HeadingInfo("CreateYoutubeQRCode", "Version 0.1"); HelpText help = new HelpText(head); help.Copyright = new CopyrightInfo("KAJIWARA Yutaka", 2015); //全オプションを表示(1行間隔) help.AdditionalNewLineAfterOption = true; help.AddOptions(this); return help.ToString(); }
public void Add_options_with_dashes() { var local = new HelpText { AddDashesToOption = true, Heading = new HeadingInfo("AddOptionsWithDashes"), Copyright = new CopyrightInfo("Author", DateTime.Now.Year) }; local.AddOptions(new MockOptionsSimple()); string help = local.ToString(); Console.WriteLine(help); string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); lines[3].Should().Be(" -s, --something Input something here."); }
public string GetUsage() { var help = new HelpText("GeoIp Example runner", "Copyright 2013", this); // ... if (this.LastParserState.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); } } // ... return help.ToString(); }
public static string GetSubCommandHelpMessage(object option, string[] usages) { var helpText = new HelpText(HelpText) { AdditionalNewLineAfterOption = false, AddDashesToOption = true }; bool multiple = usages.Length > 1; for (int i = 0; i < usages.Length; i++) { string title = multiple ? $"Usage{i + 1}" : "Usage"; AddLinesToHelpText(helpText, $"{Environment.NewLine}{title}: {ProductName} {usages[i]}"); } helpText.AddOptions(option); return helpText.ToString(); }
public string GetUsage() { var versionInfo = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location); // AssemblyCopyrightAttribute asmcpy = (AssemblyCopyrightAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyCopyrightAttribute)); //ヘッダーの設定 HeadingInfo head = new HeadingInfo(versionInfo.ProductName, "Version " + versionInfo.ProductVersion); HelpText help = new HelpText(head); help.Copyright = new CopyrightInfo("T. Minemoto", 2010); help.AddPreOptionsLine("University of Hyogo, Research Group of Fundamental Computer Engineering"); help.AddPreOptionsLine("Usage: MorphExtractroCL.exe -i D:\\input -o out -b 123"); //全オプションを表示(1行間隔) help.AdditionalNewLineAfterOption = false; help.AddOptions(this); return help.ToString(); }
public void Create_instance_with_enum_options_disabled() { // Fixture setup // Exercize system var sut = new HelpText { AddDashesToOption = true } .AddPreOptionsLine("pre-options") .AddOptions(new FakeOptionsWithHelpTextEnum()) .AddPostOptionsLine("post-options"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); Assert.Equal("pre-options", lines[0]); Assert.Equal("--stringvalue Define a string value here.", lines[1]); Assert.Equal("--shape Define a enum value here.", lines[2]); Assert.Equal("--help Display this help screen.", lines[3]); Assert.Equal("post-options", lines[4]); // Teardown }
public void Create_instance_with_enum_options_disabled() { // Fixture setup // Exercize system var sut = new HelpText { AddDashesToOption = true } .AddPreOptionsLine("pre-options") .AddOptions(new NotParsed<FakeOptionsWithHelpTextEnum>(TypeInfo.Create(typeof(FakeOptionsWithHelpTextEnum)), Enumerable.Empty<Error>())) .AddPostOptionsLine("post-options"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); lines[0].ShouldBeEquivalentTo("pre-options"); lines[1].ShouldBeEquivalentTo("--stringvalue Define a string value here."); lines[2].ShouldBeEquivalentTo("--shape Define a enum value here."); lines[3].ShouldBeEquivalentTo("--help Display this help screen."); lines[4].ShouldBeEquivalentTo("--version Display version information."); lines[5].ShouldBeEquivalentTo("post-options"); // Teardown }
public void Create_instance_without_options() { // Fixture setup // Exercize system var sut = new HelpText(new HeadingInfo("Unit-tests", "2.0"), new CopyrightInfo(true, "Author", 2005, 2013)) .AddPreOptionsLine("pre-options line 1") .AddPreOptionsLine("pre-options line 2") .AddPostOptionsLine("post-options line 1") .AddPostOptionsLine("post-options line 2"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines(); lines[0].ShouldBeEquivalentTo("Unit-tests 2.0"); lines[1].ShouldBeEquivalentTo("Copyright (C) 2005 - 2013 Author"); lines[2].ShouldBeEquivalentTo("pre-options line 1"); lines[3].ShouldBeEquivalentTo("pre-options line 2"); lines[4].ShouldBeEquivalentTo("post-options line 1"); lines[5].ShouldBeEquivalentTo("post-options line 2"); // Teardown }
public void Create_instance_with_options() { // Fixture setup // Exercize system var sut = new HelpText { AddDashesToOption = true } .AddPreOptionsLine("pre-options") .AddOptions(new NotParsed<Simple_Options>(TypeInfo.Create(typeof(Simple_Options)), Enumerable.Empty<Error>())) .AddPostOptionsLine("post-options"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); lines[0].ShouldBeEquivalentTo("pre-options"); lines[1].ShouldBeEquivalentTo("--stringvalue Define a string value here."); lines[2].ShouldBeEquivalentTo("-s, --shortandlong Example with both short and long name."); lines[3].ShouldBeEquivalentTo("-i Define a int sequence here."); lines[4].ShouldBeEquivalentTo("-x Define a boolean or switch value here."); lines[5].ShouldBeEquivalentTo("--help Display this help screen."); lines[6].ShouldBeEquivalentTo("--version Display version information."); lines[7].ShouldBeEquivalentTo("value pos. 0 Define a long value here."); lines[8].ShouldBeEquivalentTo("post-options"); // Teardown }
public void Create_instance_with_options_and_values() { // Fixture setup // Exercize system var sut = new HelpText { AddDashesToOption = true } .AddPreOptionsLine("pre-options") .AddOptions(new FakeOptionsWithHelpTextValue()) .AddPostOptionsLine("post-options"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); Assert.Equal("pre-options", lines[0]); Assert.Equal("--stringvalue=STR Define a string value here.", lines[1]); Assert.Equal("-i INTSEQ Define a int sequence here.", lines[2]); Assert.Equal("-x Define a boolean or switch value here.", lines[3]); Assert.Equal("--help Display this help screen.", lines[4]); Assert.Equal("--version Display version information.", lines[5]); Assert.Equal("number (pos. 0) NUM Define a long value here.", lines[6]); Assert.Equal("paintcolor (pos. 1) COLOR Define a color value here.", lines[7]); Assert.Equal("post-options", lines[8]); // Teardown }
public void When_help_text_is_longer_than_width_it_will_wrap_around_as_if_in_a_column() { // Fixture setup // Exercize system var sut = new HelpText(new HeadingInfo("CommandLine.Tests.dll", "1.9.4.131")); sut.MaximumDisplayWidth = 40; sut.AddOptions( new NotParsed<FakeOptionsWithLongDescription>( TypeInfo.Create(typeof(FakeOptionsWithLongDescription)), Enumerable.Empty<Error>())); // Verify outcome var lines = sut.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None); lines[2].ShouldBeEquivalentTo(" v, verbose This is the description"); //"The first line should have the arguments and the start of the Help Text."); //string formattingMessage = "Beyond the second line should be formatted as though it's in a column."; lines[3].ShouldBeEquivalentTo(" of the verbosity to "); lines[4].ShouldBeEquivalentTo(" test out the wrapping "); lines[5].ShouldBeEquivalentTo(" capabilities of the "); lines[6].ShouldBeEquivalentTo(" Help Text."); // Teardown }
public void When_defined_MetaValue_should_be_rendered() { // Fixture setup // Exercize system var sut = new HelpText("Meta Value.").AddOptions( new NotParsed<FakeOptionsWithMetaValue>(TypeInfo.Create(typeof(FakeOptionsWithMetaValue)), Enumerable.Empty<Error>())); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); lines[2].ShouldBeEquivalentTo("i FILE, input-file=FILE Required. Specify input FILE to be processed."); // Teardown }
public void Long_pre_and_post_lines_without_spaces() { // Fixture setup // Exercize system var sut = new HelpText("Heading Info."); sut.MaximumDisplayWidth = 40; sut.AddPreOptionsLine("Before 0123456789012345678901234567890123456789012 After") .AddOptions(new NotParsed<FakeOptionsForHelp>(TypeInfo.Create(typeof(FakeOptionsForHelp)), Enumerable.Empty<Error>())) .AddPostOptionsLine("Before 0123456789012345678901234567890123456789 After"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines(); lines[1].ShouldBeEquivalentTo("Before "); lines[2].ShouldBeEquivalentTo("0123456789012345678901234567890123456789"); lines[3].ShouldBeEquivalentTo("012 After"); lines[lines.Length - 3].ShouldBeEquivalentTo("Before "); lines[lines.Length - 2].ShouldBeEquivalentTo("0123456789012345678901234567890123456789"); lines[lines.Length - 1].ShouldBeEquivalentTo(" After"); // Teardown }
public void Long_help_text_without_spaces() { // Fixture setup // Exercize system var sut = new HelpText(new HeadingInfo("CommandLine.Tests.dll", "1.9.4.131")); sut.MaximumDisplayWidth = 40; sut.AddOptions( new NotParsed<FakeOptionsWithLongDescriptionAndNoSpaces>( TypeInfo.Create(typeof(FakeOptionsWithLongDescriptionAndNoSpaces)), Enumerable.Empty<Error>())); // Verify outcome var lines = sut.ToString().ToNotEmptyLines(); lines[1].ShouldBeEquivalentTo(" v, verbose Before "); lines[2].ShouldBeEquivalentTo(" 012345678901234567890123"); lines[3].ShouldBeEquivalentTo(" After"); lines[4].ShouldBeEquivalentTo(" input-file Before "); lines[5].ShouldBeEquivalentTo(" 012345678901234567890123"); lines[6].ShouldBeEquivalentTo(" 456789 After"); // Teardown }
public void Create_instance_with_options_and_values() { // Fixture setup // Exercize system var sut = new HelpText { AddDashesToOption = true } .AddPreOptionsLine("pre-options") .AddOptions(new NotParsed<FakeOptionsWithHelpTextValue>(TypeInfo.Create(typeof(FakeOptionsWithHelpTextValue)), Enumerable.Empty<Error>())) .AddPostOptionsLine("post-options"); // Verify outcome var lines = sut.ToString().ToNotEmptyLines().TrimStringArray(); lines[0].ShouldBeEquivalentTo("pre-options"); lines[1].ShouldBeEquivalentTo("--stringvalue=STR Define a string value here."); lines[2].ShouldBeEquivalentTo("-i INTSEQ Define a int sequence here."); lines[3].ShouldBeEquivalentTo("-x Define a boolean or switch value here."); lines[4].ShouldBeEquivalentTo("--help Display this help screen."); lines[5].ShouldBeEquivalentTo("--version Display version information."); lines[6].ShouldBeEquivalentTo("number (pos. 0) NUM Define a long value here."); lines[7].ShouldBeEquivalentTo("paintcolor (pos. 1) COLOR Define a color value here."); lines[8].ShouldBeEquivalentTo("post-options", lines[8]); // Teardown }
public void Post_options_lines_feature_added() { var local = new HelpText("Heading Info."); local.AddPreOptionsLine("This is a first pre-options line."); local.AddPreOptionsLine("This is a second pre-options line."); local.AddOptions(new MockOptions()); local.AddPostOptionsLine("This is a first post-options line."); local.AddPostOptionsLine("This is a second post-options line."); string help = local.ToString(); string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); lines[lines.Length - 2].Should().Be("This is a first post-options line."); lines[lines.Length - 1].Should().Be("This is a second post-options line."); }
public void Long_pre_and_post_lines_without_spaces() { // Fixture setup // Exercize system var sut = new HelpText("Heading Info."); sut.MaximumDisplayWidth = 40; sut.AddPreOptionsLine("Before 0123456789012345678901234567890123456789012 After") .AddOptions(new FakeOptionsForHelp()) .AddPostOptionsLine("Before 0123456789012345678901234567890123456789 After"); // Verify outcome var lines = sut.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None); lines[1].Should().Be("Before "); lines[2].Should().Be("0123456789012345678901234567890123456789"); lines[3].Should().Be("012 After"); lines[lines.Length - 3].Should().Be("Before "); lines[lines.Length - 2].Should().Be("0123456789012345678901234567890123456789"); lines[lines.Length - 1].Should().Be(" After"); // Teardown }
public void Long_help_text_without_spaces() { // Fixture setup // Exercize system var sut = new HelpText(new HeadingInfo("CommandLine.Tests.dll", "1.9.4.131")); sut.MaximumDisplayWidth = 40; sut.AddOptions(new FakeOptionsWithLongDescriptionAndNoSpaces()); // Verify outcome var lines = sut.ToString().Split(new[] { Environment.NewLine }, StringSplitOptions.None); lines[2].Should().Be(" v, verbose Before "); lines[3].Should().Be(" 012345678901234567890123"); lines[4].Should().Be(" After"); lines[5].Should().Be(" input-file Before "); lines[6].Should().Be(" 012345678901234567890123"); lines[7].Should().Be(" 456789 After"); // Teardown }
public void When_help_text_is_longer_than_width_it_will_wrap_around_as_if_in_a_column() { var helpText = new HelpText(new HeadingInfo("CommandLine.Tests.dll", "1.9.4.131")); helpText.MaximumDisplayWidth = 40; helpText.AddOptions(new MockOptionsWithLongDescription()); string help = helpText.ToString(); string[] lines = help.Split(new[] {Environment.NewLine}, StringSplitOptions.None); lines[2].Should().Be(" v, verbose This is the description"); //"The first line should have the arguments and the start of the Help Text."); //string formattingMessage = "Beyond the second line should be formatted as though it's in a column."; lines[3].Should().Be(" of the verbosity to "); lines[4].Should().Be(" test out the wrapping "); lines[5].Should().Be(" capabilities of the "); lines[6].Should().Be(" Help Text."); }
public string GetUsage() { var help = new HelpText { AddDashesToOption = true }; help.AddPreOptionsLine("!countdown -d <duration> -i <interval> [options]"); help.AddOptions(this); return help.ToString().Replace("System.String[]", "Finished!"); }
public void Customize_options_format() { var local = new HelpText("Customizing Test."); local.FormatOptionHelpText += new EventHandler<FormatOptionHelpTextEventArgs>(CustomizeOptionsFormat_FormatOptionHelpText); local.AddPreOptionsLine("Pre-Options."); local.AddOptions(new MockOptionsWithDescription()); local.AddPostOptionsLine("Post-Options."); string help = local.ToString(); Console.WriteLine(help); string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); lines[0].Should().Be("Customizing Test."); lines[1].Should().Be("Pre-Options."); lines[3].Should().Be(" v, verbose Kommentar umfassend Operationen."); lines[4].Should().Be(" i, input-file Erforderlich. Gibt den Eingang an zu bearbeitenden Datei."); lines[6].Should().Be("Post-Options."); }
public void Create_basic_instance() { var local = new HelpText(); local.ToString().Should().Be(""); }