예제 #1
0
            public PositionalArgumentComposer(
                Action <T> callback,
                CommandLineParserConfigurator configurator,
                Action <Argument> addToArguments,
                Action <Argument> addToRequired,
                Action <Help.Help> addToHelp)
                : base(configurator)
            {
                this.addToRequired = addToRequired;

                this.current = new PositionalArgument <T>(callback);
                this.help    = new PositionalHelp <T>(this.current);

                addToArguments(this.current);
                addToHelp(this.help);
            }
예제 #2
0
            public SwitchComposer(
                string name,
                Action callback,
                CommandLineParserConfigurator configurator,
                Action <Argument> addToArguments,
                Action <string, IArgumentWithName> addLongAlias,
                Action <Help.Help> addHelp)
                : base(configurator)
            {
                this.addLongAlias = addLongAlias;

                this.current = new Switch(name, callback);
                this.help    = new SwitchHelp(this.current);

                addToArguments(this.current);
                addHelp(this.help);
            }
예제 #3
0
            public NamedArgumentComposer(
                string name,
                Action <T> callback,
                CommandLineParserConfigurator configurator,
                Action <Argument> addToArguments,
                Action <string, IArgumentWithName> addLongAlias,
                Action <IArgument> addToRequired,
                Action <Help.Help> addToHelp)
                : base(configurator)
            {
                this.addLongAlias  = addLongAlias;
                this.addToRequired = addToRequired;

                this.current = new NamedArgument <T>(name, callback);
                this.help    = new NamedHelp <T>(this.current);

                addToArguments(this.current);
                addToHelp(this.help);
            }
예제 #4
0
        public void UnknownArgument(
            string[] args,
            CommandLineConfiguration configuration,
            UsageComposer usageComposer,
            Usage usage)
        {
            "establish a parsing configuration".x(() =>
            {
                configuration = CommandLineParserConfigurator
                                .Create()
                                .WithNamed("optional", Dummy)
                                .DescribedBy("placeholder", "optional description")
                                .WithNamed("required", Dummy)
                                .Required()
                                .DescribedBy("placeholder", "required description")
                                .BuildConfiguration();
            });

            "establish a usage composer using the parsing configuration".x(() =>
            {
                usageComposer = new UsageComposer(configuration);
            });

            "when composing usage".x(() =>
                                     usage = usageComposer.Compose());

            "should list arguments".x(() =>
                                      usage.Arguments
                                      .Should().Contain("-optional <placeholder>")
                                      .And.Contain("-required <placeholder>"));

            "should show whether an argument is optional or required".x(() =>
                                                                        (usage.Arguments + " ")
                                                                        .Should().Contain("[-optional <placeholder>]")
                                                                        .And.Contain(" -required <placeholder> "));

            "should list options per argument with description".x(() =>
                                                                  usage.Options
                                                                  .Should().Contain("optional description")
                                                                  .And.Contain("required description"));
        }
 public CommandLineParserConfiguratorFacts()
 {
     this.testee = new CommandLineParserConfigurator();
 }
예제 #6
0
 protected Composer(CommandLineParserConfigurator configurator)
 {
     this.configurator = configurator;
 }