public static CLIExitCode ParseCommandLineArguments()

in Configurator/Core/CLI/CommandLineParser.cs [224:272]


    public static CLIExitCode ParseCommandLineArguments(string[] arguments)
    {
      if (arguments == null
          || arguments.Length == 0)
      {
        throw new ArgumentNullException(nameof(arguments));
      }

      ProvidedOptions.Clear();
      foreach (var argument in arguments)
      {
        var argumentParsingResult = ParseArgument(argument);
        if (argumentParsingResult.ExitCode != ExitCode.Success)
        {
          return argumentParsingResult;
        }
      }

      var consoleOption = GetMatchingProvidedOption("console");
      var actionOption = GetMatchingProvidedOption("action");
      var helpOption = GetMatchingProvidedOption("help");
      AppConfiguration.ConsoleMode = consoleOption != null;
      if (consoleOption != null)
      {
        ProvidedOptions.Remove(consoleOption);
      }

      if ((!AppConfiguration.ConsoleMode
           && (((actionOption != null
                 && !actionOption.Value.Equals("configure", StringComparison.InvariantCultureIgnoreCase)
                 && !actionOption.Value.Equals("reconfigure", StringComparison.InvariantCultureIgnoreCase)
                 && !actionOption.Value.Equals("remove", StringComparison.InvariantCultureIgnoreCase)
                 && !actionOption.Value.Equals("removenoshow", StringComparison.InvariantCultureIgnoreCase))
                || (actionOption == null 
                    && ProvidedOptions.Count > 0))))
         || (AppConfiguration.ConsoleMode
             && helpOption != null
             && ((actionOption == null
                  && ProvidedOptions.Count > 1)
                  || (actionOption != null
                      && ProvidedOptions.Count > 2))))
      {
        // If console option was not provided and action is different than configure, reconfigure or remove
        // then the combination is not supported.
        return new CLIExitCode(ExitCode.TooManyArguments);
      }

      return new CLIExitCode(ExitCode.Success);
    }