Ejemplo n.º 1
0
        public ISubCommand Create()
        {
            var args = _args;

            if (args.Length > 0)
            {
                // Drawback: do not support such case: docfx --force <subcommands>
                var subCommandName = args[0];
                if (TryGetCommandCreator(subCommandName, out ISubCommandCreator command))
                {
                    var subArgs = args.Skip(1).ToArray();
                    return(command.Create(subArgs, this, SubCommandParseOption.Strict));
                }
            }

            // TODO: comment: also handle log and loglevel like in build command
            // WONT FIX: log and loglevel will be handled in each sub-command as passed in by options
            var  options = new CompositeOptions();
            var  parser  = CommandUtility.GetParser(SubCommandParseOption.Loose);
            bool parsed  = parser.ParseArguments(args, options);

            if (options.ShouldShowVersion)
            {
                return(new HelpCommand(GetVersionText()));
            }
            if (options.IsHelp)
            {
                return(new HelpCommand(GetHelpText()));
            }
            return(new CompositeCommand(args, this, options));
        }
Ejemplo n.º 2
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));
                }
            }
        }
Ejemplo n.º 3
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));
         }
     }
 }
Ejemplo 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);
        }
Ejemplo n.º 5
0
        public ISubCommand Create()
        {
            var args = _args;
            if (args.Length > 0)
            {
                // Drawback: do not support such case: docfx --force <subcommands>
                var subCommandName = args[0];
                ISubCommandCreator command;
                if (TryGetCommandCreator(subCommandName, out command))
                {
                    var subArgs = args.Skip(1).ToArray();
                    return command.Create(subArgs, this, SubCommandParseOption.Strict);
                }
            }

            // TODO: comment: also handle log and loglevel like in build command
            // WONT FIX: log and loglevel will be handled in each sub-command as passed in by options
            var options = new CompositeOptions();
            var parser = CommandUtility.GetParser(SubCommandParseOption.Loose);
            bool parsed = parser.ParseArguments(args, options);
            if (options.IsHelp) return new HelpCommand(GetHelpText());
            return new CompositeCommand(args, this, options);
        }