Пример #1
0
        // See if the given commandLine starts with a valid environment name. If so,
        // extract the environment name from the front and return the remainder of the
        // commandline.
        private (string startingEnvironment, string commandLine) GetStartingEnvironment(string commandLine)
        {
            var validEnvironments = Environments.GetNames();

            if (validEnvironments.Count <= 1)
            {
                return(null, commandLine);
            }

            var parts = commandLine.Split(new[] { ' ' }, 2);
            var env   = parts[0];

            return(Environments.IsValid(env) ? (env, parts[1]) : (null, commandLine));
Пример #2
0
        /// <summary>
        /// Selects the appropriate run mode and executes it. If a command is provided, the
        /// application is inferred to be in headless mode. If no arguments are provided
        /// the application is inferred to be in interactive mode.
        /// </summary>
        /// <param name="commandLine"></param>
        public int Run(string commandLine)
        {
            // If there are no arguments, enter interactive mode
            if (string.IsNullOrEmpty(commandLine))
            {
                return(RunInteractively());
            }

            // if there is exactly one argument and it's the name of a valid environment,
            // start interactive mode setting that environment first.
            if (Environments.IsValid(commandLine))
            {
                return(RunInteractively(commandLine));
            }

            // Otherwise run in headless mode and figure it out from there.
            return(RunHeadless(commandLine));
        }