Пример #1
0
 public IEnumerable <HelpSectionDelegate> CustomHelpLayout()
 {
     yield return((context) =>
     {
         if (context.ParseResult.CommandResult.Command is not NewCommand newCommand)
         {
             throw new ArgumentException($"{nameof(context)} should be for {nameof(NewCommand)}");
         }
         NewCommandArgs args = new NewCommandArgs(newCommand, context.ParseResult);
         using IEngineEnvironmentSettings environmentSettings = CreateEnvironmentSettings(args, context.ParseResult);
         InstantiateCommandArgs instantiateCommandArgs = InstantiateCommandArgs.FromNewCommandArgs(args);
         InstantiateCommand.WriteHelp(context, instantiateCommandArgs, environmentSettings);
     });
 }
Пример #2
0
        public InstantiateCommandArgs(InstantiateCommand command, ParseResult parseResult) : base(command, parseResult)
        {
            RemainingArguments = parseResult.GetValueForArgument(command.RemainingArguments) ?? Array.Empty <string>();
            ShortName          = parseResult.GetValueForArgument(command.ShortNameArgument);

            var tokens = new List <string>();

            if (!string.IsNullOrWhiteSpace(ShortName))
            {
                tokens.Add(ShortName);
            }
            tokens.AddRange(RemainingArguments);
            TokensToInvoke = tokens.ToArray();
        }