예제 #1
0
        public void ManuallyAddedOptionIsPreservedOnTemplateSubcommandLevel()
        {
            ITemplateEngineHost host      = TestHost.GetVirtualHost(additionalComponents: BuiltInTemplatePackagesProviderFactory.GetComponents(includeTestTemplates: false));
            NewCommand          myCommand = (NewCommand)NewCommandFactory.Create("new", _ => host, _ => new TelemetryLogger(null, false), new NewCommandCallbacks());

            var customOption = new Option <string>("--newOption");

            myCommand.AddGlobalOption(customOption);

            var parseResult             = myCommand.Parse("new console --newOption val");
            InstantiateCommandArgs args = InstantiateCommandArgs.FromNewCommandArgs(new NewCommandArgs(myCommand, parseResult));

            Assert.NotNull(args.ParseResult);
            Assert.Equal("console", args.ShortName);
            Assert.Empty(args.RemainingArguments);
            Assert.Equal("val", args.ParseResult.GetValueForOption(customOption));
        }