Exemplo n.º 1
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.º 2
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.º 3
0
        public string GetUsage()
        {
            var help = new HelpText
            {
                Heading   = new HeadingInfo("<>", "<>"),
                Copyright = new CopyrightInfo("<>", 2017),
                AdditionalNewLineAfterOption = false,
                AddDashesToOption            = true
            };

            help.AddPreOptionsLine("<>");
            help.AddPreOptionsLine("Usage: app -pSomeone");
            help.AddOptions(this);
            return(help);
        }
Exemplo n.º 4
0
        public string GetUsage()
        {
            var help = new HelpText()
            {
                Heading   = new HeadingInfo("Db Migrator", "1.0.0"),
                Copyright = new CopyrightInfo("RMS", 2015),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = true
            };

            help.AddPreOptionsLine("");
            help.AddPreOptionsLine("Usage: dbmigrator -p value");
            help.AddOptions(this);
            return(help);
        }
        public string GetUsage()
        {
            var help = new HelpText
            {
                Heading   = new HeadingInfo("Atlas Texture Packer", "v 1.0.0"),
                Copyright = new CopyrightInfo("Lucas Lundy", 2016),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = true
            };

            help.AddPreOptionsLine("MIT");
            help.AddPreOptionsLine("Usage: app -i \\\\Input\\Path -o \\\\Output\\Path");
            help.AddOptions(this);
            return(help);
        }
Exemplo n.º 6
0
        public string GetUsage()
        {
            var help = new HelpText
            {
                Heading   = new HeadingInfo("CovrIn Runner", "0.1"),
                Copyright = new CopyrightInfo("Konrad M. Kruczyński, Piotr Zierhoffer", 2015),
                AdditionalNewLineAfterOption = true,
                AddDashesToOption            = true
            };

            help.AddPreOptionsLine("");
            help.AddPreOptionsLine("Usage: Runner.exe [-o OutputDirectory] [-a AnalysisFileName] AssemblyFileOrDirectory...");
            help.AddOptions(this);
            return(help);
        }
Exemplo n.º 7
0
        public void CustomizeOptionsFormat()
        {
            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);
            Assert.AreEqual("Customizing Test.", lines[0]);
            Assert.AreEqual("Pre-Options.", lines[1]);
            Assert.AreEqual("  v, verbose       Kommentar umfassend Operationen.", lines[3]);
            Assert.AreEqual("  i, input-file    Erforderlich. Gibt den Eingang an zu bearbeitenden Datei.", lines[4]);
            Assert.AreEqual("Post-Options.", lines[6]);
        }
Exemplo n.º 8
0
        public void InstancingWithParameterlessConstructor()
        {
            var year = DateTime.Now.Year;
            var local = new HelpText();
            local.Heading = new HeadingInfo("Parameterless Constructor Test.");
            local.Copyright = new CopyrightInfo("Author", year);
            local.AddPreOptionsLine("Pre-Options.");
            local.AddOptions(new MockOptionsSimple());
            local.AddPostOptionsLine("Post-Options.");

            string help = local.ToString();

            Console.WriteLine(help);

            string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.AreEqual("Parameterless Constructor Test.", lines[0]);
            Assert.AreEqual(string.Format(CultureInfo.InvariantCulture, "Copyright (C) {0} Author", year), lines[1]);
            Assert.AreEqual("Pre-Options.", lines[2]);
            Assert.AreEqual("  s, something    Input something here.", lines[4]);
            Assert.AreEqual("Post-Options.", lines[6]);
        }
Exemplo n.º 9
0
        public void PostOptionsLinesFeatureAdded()
        {
            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);
            Assert.AreEqual(lines[lines.Length - 2], "This is a first post-options line.");
            Assert.AreEqual(lines[lines.Length - 1], "This is a second post-options line.");
        }
Exemplo n.º 10
0
        public void LongPreAndPostLinesWithoutSpaces()
        {
            var local = new HelpText("Heading Info.");
            local.MaximumDisplayWidth = 40;
            local.AddPreOptionsLine("Before 0123456789012345678901234567890123456789012 After");
            local.AddOptions(new MockOptions());
            local.AddPostOptionsLine("Before 0123456789012345678901234567890123456789 After");

            string help = local.ToString();

            string[] lines = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.AreEqual("Before ", lines[1]);
            Assert.AreEqual("0123456789012345678901234567890123456789", lines[2]);
            Assert.AreEqual("012 After", lines[3]);
            Assert.AreEqual("Before ", lines[lines.Length - 3]);
            Assert.AreEqual("0123456789012345678901234567890123456789", lines[lines.Length - 2]);
            Assert.AreEqual(" After", lines[lines.Length - 1]);
        }
Exemplo n.º 11
0
            public string GetUsage()
            {
                var help = new HelpText(new HeadingInfo("unittest", "1.9"));
                help.AdditionalNewLineAfterOption = true;
                help.Copyright = new CopyrightInfo("CommandLine.dll Author", 2005, 2011);

                // handling parsing error code
                string 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("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: Please run the unit...");
                help.AddOptions(this);

                return help;
            }
Exemplo n.º 12
0
 public void Add_an_empty_pre_options_line_is_allowed()
 {
     var helpText = new HelpText(new HeadingInfo("CommandLine.Tests.dll", "1.9.4.131"));
     helpText.AddPreOptionsLine(string.Empty);
 }
Exemplo n.º 13
0
        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.");
        }
Exemplo n.º 14
0
        public void Long_pre_and_post_lines_without_spaces()
        {
            var local = new HelpText("Heading Info.");
            local.MaximumDisplayWidth = 40;
            local.AddPreOptionsLine("Before 0123456789012345678901234567890123456789012 After");
            local.AddOptions(new MockOptions());
            local.AddPostOptionsLine("Before 0123456789012345678901234567890123456789 After");

            string help = local.ToString();

            string[] lines = help.Split(new string[] { 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");
        }