Example #1
0
        public void Failed_verb_parsing_prints_particular_help_screen()
        {
            string invokedVerb         = null;
            object invokedVerbInstance = null;

            var options    = new OptionsWithVerbsHelp();
            var testWriter = new StringWriter();

            ReflectionHelper.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLine.Parser(with => with.HelpWriter = testWriter);
            var result = parser.ParseArguments(new string[] { "clone", "--no_hardlinks" }, options,
                                               (verb, subOptions) =>
            {
                invokedVerb         = verb;
                invokedVerbInstance = subOptions;
            });

            result.Should().BeFalse();

            var helpText = testWriter.ToString();

            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            // Verify just significant output
            lines[5].Trim().Should().Be("--no-hardlinks    Optimize the cloning process from a repository on a local");
            lines[6].Trim().Should().Be("filesystem by copying files.");
            lines[7].Trim().Should().Be("-q, --quiet       Suppress summary message.");

            invokedVerb.Should().Be("clone");
            invokedVerbInstance.Should().Be(null);
        }
Example #2
0
        public void Requesting_help_of_particular_verb_without_instance_should_work()
        {
            string invokedVerb         = null;
            object invokedVerbInstance = null;

            var options    = new OptionsWithVerbsHelp();
            var testWriter = new StringWriter();

            ReflectionHelper.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLine.Parser(with => with.HelpWriter = testWriter);
            var result = parser.ParseArguments(new string[] { "help", "add" }, options,
                                               (verb, subOptions) =>
            {
                invokedVerb         = verb;
                invokedVerbInstance = subOptions;
            });

            result.Should().BeFalse();

            var helpText = testWriter.ToString();

            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            invokedVerb.Should().Be("help");
            invokedVerbInstance.Should().Be(null);
        }
Example #3
0
        private void DoCoreTestForIndex(string[] args)
        {
            var options    = new OptionsWithVerbsHelp();
            var testWriter = new StringWriter();

            ReflectionHelper.AssemblyFromWhichToPullInformation = Assembly.GetExecutingAssembly();
            var parser = new CommandLine.Parser(with => with.HelpWriter = testWriter);
            var result = parser.ParseArguments(args, options,
                                               (_, __) =>
            {
            });

            result.Should().BeFalse();

            var helpText = testWriter.ToString();

            Console.WriteLine(helpText);
            var lines = helpText.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

            // Verify just significant output
            lines[5].Trim().Should().Be("add       Add file contents to the index.");
            lines[6].Trim().Should().Be("commit    Record changes to the repository.");
            lines[7].Trim().Should().Be("clone     Clone a repository into a new directory.");
        }