Exemplo n.º 1
0
        protected internal override void Execute()
        {
            ConfigCli configCli = ConfigCli.Load();

            // Command "json"
            if (UtilCli.ArgumentValueIsExist(this, argumentJson))
            {
                if (UtilCli.ArgumentValue(this, argumentJson, out string json))
                {
                    // Set ConfigCli.json with command: ".\cli.cmd config json='{}'"
                    json = json.Trim('\"');         // Remove quotation marks at the begin and end.
                    json = json.Replace("'", "\""); // To use it in command prompt.
                    // Write
                    try
                    {
                        configCli = UtilFramework.ConfigFromJson <ConfigCli>(json);
                    }
                    catch (Exception exception)
                    {
                        throw new Exception("ConfigCli invalid!", exception);
                    }
                    ConfigCli.Save(configCli);
                }
            }

            // Command "deployAzureGitUrl"
            if (UtilCli.ArgumentValueIsExist(this, argumentDeployAzureGitUrl))
            {
                if (UtilCli.ArgumentValue(this, argumentDeployAzureGitUrl, out string value))
                {
                    // Write
                    configCli.EnvironmentGet().DeployAzureGitUrl = value;
                    ConfigCli.Save(configCli);
                }
                else
                {
                    // Read
                    Console.WriteLine(argumentDeployAzureGitUrl.Name + "=" + configCli.EnvironmentGet().DeployAzureGitUrl);
                }
                return;
            }

            // Command "connectionString"
            if (UtilCli.ArgumentValueIsExist(this, argumentConnectionString))
            {
                ArgumentConnectionString();
                return;
            }

            // Command "connectionStringFramework"
            if (UtilCli.ArgumentValueIsExist(this, argumentConnectionStringFramework))
            {
                ArgumentConnectionStringFramework();
                return;
            }

            // Command "connectionStringApplication"
            if (UtilCli.ArgumentValueIsExist(this, argumentConnectionStringApplication))
            {
                ArgumentConnectionStringApplication();
                return;
            }

            // Command "website"
            if (UtilCli.ArgumentValueIsExist(this, argumentWebsite))
            {
                ArgumentWebsite();
                return;
            }

            // Print ConfigCli.json to screen
            {
                configCli = ConfigCli.Load();
                Console.WriteLine();
                UtilCli.ConsoleWriteLineColor("Add the following environment variable to ci build server: (Value including double quotation marks!)", ConsoleColor.Green);
                string json = UtilFramework.ConfigToJson(configCli, isIndented: false);
                json = json.Replace("\"", "'"); // To use it in command prompt.
                UtilCli.ConsoleWriteLineColor("ConfigCli=", ConsoleColor.DarkGreen);
                UtilCli.ConsoleWriteLineColor(string.Format("\"{0}\"", json), ConsoleColor.DarkGreen);
                Console.WriteLine();
            }
        }