Esempio n. 1
0
 public override HelpCommand CreateCommand(HelpCommandOptions options, ISubCommandController controller)
 {
     if (string.IsNullOrEmpty(options.Command))
     {
         return(new HelpCommand(controller.GetHelpText()));
     }
     if (controller.TryGetCommandCreator(options.Command, out ISubCommandCreator creator))
     {
         return(new HelpCommand(creator.GetHelpText()));
     }
     else
     {
         throw new OptionParserException($"{options.Command} is not a supported sub command.");
     }
 }
Esempio n. 2
0
 public CompositeCommand(string[] args, ISubCommandController controller, CompositeOptions options)
 {
     var result = ToOrderedKeyValuePair(options.ConfigFile);
     foreach (var pair in result)
     {
         ISubCommandCreator command;
         if (!controller.TryGetCommandCreator(pair.Key, out command))
         {
             Logger.LogWarning($"{pair.Key} is not a recognized command name, ignored.");
         }
         else
         {
             Commands.Add(command.Create(args, controller, SubCommandParseOption.Loose));
         }
     }
 }
Esempio n. 3
0
        public CompositeCommand(string[] args, ISubCommandController controller, CompositeOptions options)
        {
            var result = ToOrderedKeyValuePair(options.ConfigFile);

            foreach (var pair in result)
            {
                if (!controller.TryGetCommandCreator(pair.Key, out ISubCommandCreator command))
                {
                    Logger.LogWarning($"{pair.Key} is not a recognized command name, ignored.");
                }
                else
                {
                    Commands.Add(command.Create(args, controller, SubCommandParseOption.Loose));
                }
            }
        }
Esempio n. 4
0
        public CompositeCommand(string[] args, ISubCommandController controller, CompositeOptions options)
        {
            var result = ToOrderedKeyValuePair(options.ConfigFile);

            foreach (var pair in result)
            {
                if (!controller.TryGetCommandCreator(pair.Key, out ISubCommandCreator command))
                {
                    if (!pair.Key.Equals("$schema", StringComparison.Ordinal))
                    {
                        Logger.LogWarning($"{pair.Key} is not a recognized command name, ignored.");
                    }
                }
                else
                {
                    Commands.Add(command.Create(args, controller, SubCommandParseOption.Loose));
                }
            }

            AllowReplay = Commands.Any(c => c.AllowReplay);
        }