Exemplo n.º 1
0
        public void Run(TerraformApplySettings settings)
        {
            var builder = new ProcessArgumentBuilder()
                          .Append("apply");

            // Order of AutoApprove and Plan are important.
            if (settings.AutoApprove)
            {
                builder.Append("-auto-approve");
            }

            // Use Plan if it exists.
            if (settings.Plan != null)
            {
                builder.Append(settings.Plan.FullPath);
            }

            if (!string.IsNullOrEmpty(settings.InputVariablesFile))
            {
                builder.AppendSwitchQuoted("-var-file", $"{settings.InputVariablesFile}");
            }

            if (settings.InputVariables != null)
            {
                foreach (var inputVariable in settings.InputVariables)
                {
                    builder.AppendSwitchQuoted("-var", $"{inputVariable.Key}={inputVariable.Value}");
                }
            }

            Run(settings, builder);
        }
Exemplo n.º 2
0
        public void Run(TerraformPlanSettings settings)
        {
            var builder = new ProcessArgumentBuilder()
                          .Append("plan")
                          .Append($"-out={settings.OutFile}")
                          .Append("-detailed-exitcode");

            if (settings.Parallelism > 0)
            {
                builder = builder.Append($"-parallelism={settings.Parallelism}");
            }

            if (settings.Destroy)
            {
                builder = builder.Append("-destroy");
            }

            if (!string.IsNullOrEmpty(settings.InputVariablesFile))
            {
                builder.AppendSwitchQuoted("-var-file", $"{settings.InputVariablesFile}");
            }

            if (settings.InputVariables != null)
            {
                foreach (var inputVariable in settings.InputVariables)
                {
                    builder.AppendSwitchQuoted("-var", $"{inputVariable.Key}={inputVariable.Value}");
                }
            }

            Run(settings, builder);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Evaluates the settings and writes them to <paramref name="args"/>.
        /// </summary>
        /// <param name="args">The argument builder into which the settings should be written.</param>
        protected override void EvaluateCore(ProcessArgumentBuilder args)
        {
            const string separator = " ";

            base.EvaluateCore(args);

            if (string.IsNullOrWhiteSpace(Library))
            {
                throw new ArgumentNullException(nameof(Library), $"Missing required {nameof(Library)} property.");
            }

            args.Append(Library);

            if (Destination != null)
            {
                args.AppendSwitchQuoted("--destination", separator, Destination.FullPath);
            }

            if (Provider != CdnProvider.Default)
            {
                args.AppendSwitch("--provider", separator, Provider.ToString());
            }

            foreach (var file in Files)
            {
                args.AppendSwitchQuoted("--files", separator, file.FullPath);
            }
        }
Exemplo n.º 4
0
        public void Run(TerraformApplySettings settings)
        {
            var builder = new ProcessArgumentBuilder()
                          .Append("apply");

            // Order of AutoApprove and Plan are important.
            if (settings.AutoApprove)
            {
                builder.Append("-auto-approve");
            }

            // Use Plan if it exists.
            if (settings.Plan != null)
            {
                builder.AppendQuoted(settings.Plan.FullPath);
            }

            if (settings.Parallelism != default(int))
            {
                builder.AppendSwitch("-parallelism", "=", settings.Parallelism.ToString());
            }

            if (!string.IsNullOrWhiteSpace(settings.InputVariablesFile))
            {
                builder.AppendSwitchQuoted("-var-file", $"{settings.InputVariablesFile}");
            }

            foreach (var inputVariable in settings.InputVariables ?? new Dictionary <string, string>())
            {
                builder.AppendSwitchQuoted("-var", $"{inputVariable.Key}={inputVariable.Value}");
            }

            Run(settings, builder);
        }
Exemplo n.º 5
0
        internal static ProcessArgumentBuilder BuildForWindows(this AzCopySettings settings, string source, string destination)
        {
            var args = new ProcessArgumentBuilder();

            args.AppendSwitchQuoted("/Source", ":", source);
            args.AppendSwitchQuoted("/Dest", ":", destination);
            args = settings.BuildWindowsArguments(args);
            return(args);
        }
Exemplo n.º 6
0
        internal static ProcessArgumentBuilder BuildForLinux(this AzCopySettings settings, string source, string destination)
        {
            var args = new ProcessArgumentBuilder();

            args.AppendSwitchQuoted("--source", source);
            args.AppendSwitchQuoted("--destination", destination);
            args = settings.BuildLinuxArguments(args);
            return(args);
        }
Exemplo n.º 7
0
        private ProcessArgumentBuilder GetArguments(FilePath scriptFile, InnoSetupSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            // Defines (/Ddefine[=value]
            if (settings.Defines != null)
            {
                foreach (var item in settings.Defines)
                {
                    builder.Append(string.IsNullOrEmpty(item.Value)
                        ? string.Format(CultureInfo.InvariantCulture, "/D{0}", item.Key)
                        : string.Format(CultureInfo.InvariantCulture, "/D{0}={1}", item.Key,
                                        new QuotedArgument(new TextArgument(item.Value))));
                }
            }

            // Enable output
            if (settings.EnableOutput.HasValue)
            {
                builder.Append(settings.EnableOutput.Value ? "/O+" : "/O-");
            }

            // Output directory
            if (settings.OutputDirectory != null)
            {
                builder.AppendSwitchQuoted("/O", string.Empty, settings.OutputDirectory.MakeAbsolute(_environment).FullPath);
            }

            // Output base file name
            if (!string.IsNullOrEmpty(settings.OutputBaseFilename))
            {
                builder.AppendSwitchQuoted("/F", string.Empty, settings.OutputBaseFilename);
            }

            // Quiet mode
            switch (settings.QuietMode)
            {
            case InnoSetupQuietMode.Off:
                break;

            case InnoSetupQuietMode.Quiet:
                builder.Append("/Q");
                break;

            case InnoSetupQuietMode.QuietWithProgress:
                builder.Append("/Qp");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            // Quoted Script file
            builder.AppendQuoted(scriptFile.MakeAbsolute(_environment).FullPath);

            return(builder);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Assemble the args to pass to sc.exe
        /// </summary>
        /// <param name="computer"></param>
        /// <param name="settings"></param>
        /// <returns></returns>
        public ProcessArgumentBuilder CreateInstallArguments(string computer, InstallSettings settings)
        {
            ProcessArgumentBuilder args = new ProcessArgumentBuilder();

            string pathArgs = "";

            if (settings.Arguments != null)
            {
                pathArgs = settings.Arguments.Render();
            }

            this.SetFilePath(computer, settings);


            if (!String.IsNullOrEmpty(settings.ServiceName))
            {
                args.AppendQuoted(settings.ServiceName);
            }

            if (String.IsNullOrEmpty(pathArgs))
            {
                args.AppendSwitchQuoted("binPath=", " ", settings.ExecutablePath.FullPath);
            }
            else
            {
                args.AppendSwitch("binPath=", " ", "'" + @"\""" + settings.ExecutablePath.FullPath + @"\"" " + pathArgs.Replace("\"", "\\\"") + "'");
            }


            if (!String.IsNullOrEmpty(settings.DisplayName))
            {
                args.AppendSwitchQuoted("DisplayName=", " ", settings.DisplayName);
            }

            if (!String.IsNullOrEmpty(settings.Dependencies))
            {
                args.AppendSwitchQuoted("depend=", " ", settings.Dependencies);
            }

            if (!String.IsNullOrEmpty(settings.StartMode))
            {
                args.AppendSwitchQuoted("start=", " ", settings.StartMode);
            }

            if (!String.IsNullOrEmpty(settings.Username))
            {
                args.AppendSwitchQuoted("obj=", " ", settings.Username);
            }

            if (!String.IsNullOrEmpty(settings.Password))
            {
                args.AppendSwitchQuotedSecret("password="******" ", settings.Password);
            }

            return(args);
        }
Exemplo n.º 9
0
        internal static void AppendSettings(
            this ProcessArgumentBuilder arguments,
            CurlSettings settings)
        {
            if (settings.Verbose)
            {
                arguments.Append("--verbose");
            }

            if (settings.ProgressBar)
            {
                arguments.Append("--progress-bar");
            }

            if (settings.Username != null)
            {
                arguments.AppendSwitchQuoted(
                    "--user",
                    $"{settings.Username}:{settings.Password}");
            }

            if (settings.Insecure)
            {
                arguments.Append("--insecure");
            }

            if (settings.CaCertFile != null)
            {
                arguments.AppendSwitchQuoted(
                    "--cacert",
                    $"{settings.CaCertFile}");
            }

            if (settings.Headers != null)
            {
                foreach (var item in settings.Headers)
                {
                    arguments.AppendSwitchQuoted(
                        "--header",
                        $"{item.Key}:{item.Value}");
                }
            }

            if (settings.RequestCommand != null)
            {
                arguments.AppendSwitchQuoted(
                    "--request",
                    settings.RequestCommand.ToUpperInvariant());
            }

            if (settings.FollowRedirects)
            {
                arguments.Append("--location");
            }
        }
Exemplo n.º 10
0
 /// <summary>
 ///     Outputs the reporter-specific settings to include in the invocation
 /// </summary>
 /// <returns>A string to be appended to the run command.</returns>
 public void RenderOptions(ProcessArgumentBuilder args)
 {
     if (OutputFile != null)
     {
         args.AppendSwitchQuoted(ReporterArgumentNames.Html.Export, OutputFile.FullPath);
     }
     if (TemplateFile != null)
     {
         args.AppendSwitchQuoted(ReporterArgumentNames.Html.Template, TemplateFile.FullPath);
     }
 }
Exemplo n.º 11
0
        private ProcessArgumentBuilder GetArguments(OpenshiftDeleterSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("delete");

            if (!string.IsNullOrEmpty(settings.ObjectType))
            {
                builder.Append(settings.ObjectType);
            }

            if (!string.IsNullOrEmpty(settings.ObjectName))
            {
                builder.Append(settings.ObjectName);
            }

            if (!string.IsNullOrEmpty(settings.Label))
            {
                builder.AppendSwitchQuoted("--selector", "=", settings.Label);
            }

            if (settings.All)
            {
                builder.Append("--all");
            }

            // no need to specify "ignore-not-found" when the all option is set
            if (settings.IgnoreNotFound && !settings.All)
            {
                builder.Append("--ignore-not-found");
            }

            return(builder);
        }
Exemplo n.º 12
0
        private ProcessArgumentBuilder GetGradleArguments()
        {
            // USAGE: gradle [option...] [task...]
            var args = new ProcessArgumentBuilder();

            AppendLogLevel(args);

            foreach (var property in _properties)
            {
                var prefix = property.PropertyType == GradleProperty.Type.System ? "-D" : "-P";
                var key    = prefix + property.Key;

                if (property.SecretValue)
                {
                    args.AppendSwitchQuotedSecret(key, "=", property.Value);
                }
                else
                {
                    args.AppendSwitchQuoted(key, "=", property.Value);
                }
            }

            foreach (var arg in _arguments)
            {
                args.Append(arg.Trim());
            }

            if (!string.IsNullOrWhiteSpace(_tasks))
            {
                args.Append(_tasks.Trim());
            }

            return(args);
        }
Exemplo n.º 13
0
 private static void AddValue(ProcessArgumentBuilder builder, string key, string value, bool onlyAppendValue = false)
 {
     if (key.StartsWith("!", StringComparison.OrdinalIgnoreCase))
     {
         if (onlyAppendValue)
         {
             builder.AppendQuoted(value);
         }
         else
         {
             builder.AppendSwitchQuotedSecret(key.TrimStart('!'), " ", value);
         }
     }
     else
     {
         if (onlyAppendValue)
         {
             builder.AppendQuoted(value);
         }
         else
         {
             builder.AppendSwitchQuoted(key, " ", value);
         }
     }
 }
Exemplo n.º 14
0
        private static void AddValue(ProcessArgumentBuilder args, string key, string value)
        {
            var quote = value.IndexOfAny(new[] { ' ', '*' }) >= 0;

            if (key.StartsWith("!", StringComparison.OrdinalIgnoreCase))
            {
                if (quote)
                {
                    args.AppendSwitchQuotedSecret(key.TrimStart('!'), value);
                }
                else
                {
                    args.AppendSwitchSecret(key.TrimStart('!'), value);
                }
            }
            else
            {
                if (quote)
                {
                    args.AppendSwitchQuoted(key, value);
                }
                else
                {
                    args.AppendSwitch(key, value);
                }
            }
        }
Exemplo n.º 15
0
        public void Run(TerraformInitSettings settings)
        {
            var builder =
                new ProcessArgumentBuilder()
                .Append("init");

            if (settings.BackendConfigOverrides != null)
            {
                foreach (var pair in settings.BackendConfigOverrides)
                {
                    // https://www.terraform.io/docs/commands/init.html#backend-config-value
                    builder.AppendSwitchQuoted("-backend-config", $"{pair.Key}={pair.Value}");
                }
            }

            if (settings.ForceCopy)
            {
                builder.Append("-force-copy");
            }

            if (settings.ForceReconfigure)
            {
                builder.Append("-reconfigure");
            }

            Run(settings, builder);
        }
Exemplo n.º 16
0
        private ProcessArgumentBuilder GetArguments(
            FilePath coverageFile,
            FilePath testProject,
            CoverletSettings settings)
        {
            var argumentBuilder = new ProcessArgumentBuilder();

            argumentBuilder.AppendQuoted(coverageFile.MakeAbsolute(_environment).FullPath);

            argumentBuilder.AppendSwitchQuoted("--target", "dotnet");
            argumentBuilder.AppendSwitchQuoted($"--targetargs", $"test {testProject.MakeAbsolute(_environment)} --no-build");

            ArgumentsProcessor.ProcessToolArguments(settings, _environment, argumentBuilder, testProject);

            return(argumentBuilder);
        }
Exemplo n.º 17
0
        private ProcessArgumentBuilder GetArguments(CMakeBuildSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            var binaryPath = settings.BinaryPath.MakeAbsolute(_environment);

            builder.AppendSwitchQuoted("--build", binaryPath.FullPath);

            // Generator
            if (settings.CleanFirst)
            {
                builder.Append("--clean-first");
            }

            // Toolset
            if (settings.Targets != null)
            {
                builder.AppendSwitch("--target", string.Join(",", settings.Targets));
            }

            // Options
            if (settings.Options != null)
            {
                foreach (string option in settings.Options)
                {
                    builder.AppendQuoted(option);
                }
            }

            return(builder);
        }
Exemplo n.º 18
0
        private ProcessArgumentBuilder GetArguments(FilePath[] assemblies, FilePath outputPath, MonoApiInfoToolSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            if (settings.GenerateAbi)
            {
                builder.Append("--abi");
            }

            if (settings.FollowForwarders)
            {
                builder.Append("--follow-forwarders");
            }

            if (settings.SearchPaths?.Length > 0)
            {
                foreach (var path in settings.SearchPaths)
                {
                    builder.AppendSwitchQuoted("--search-directory", "=", path.MakeAbsolute(environment).FullPath);
                }
            }

            if (settings.ResolvePaths?.Length > 0)
            {
                foreach (var path in settings.ResolvePaths)
                {
                    builder.AppendSwitchQuoted("-r", "=", path.MakeAbsolute(environment).FullPath);
                }
            }

            if (outputPath != null)
            {
                builder.AppendSwitchQuoted("-o", "=", outputPath.MakeAbsolute(environment).FullPath);
            }

            if (settings.GenerateContractApi)
            {
                builder.Append("--contract-api");
            }

            foreach (var assembly in assemblies)
            {
                builder.AppendQuoted(assembly.MakeAbsolute(environment).FullPath);
            }

            return(builder);
        }
Exemplo n.º 19
0
        private ProcessArgumentBuilder GetArguments(string packageId, DotNetCoreGlobalToolInstallSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("tool");
            builder.Append("install");
            builder.Append("-g");

            if (settings.Version != null)
            {
                builder.AppendSwitchQuoted("--version", settings.Version);
            }

            if (settings.ConfigFile != null)
            {
                builder.AppendSwitchQuoted("--configfile", settings.ConfigFile);
            }

            if (settings.Source != null)
            {
                builder.AppendSwitchQuoted("--add-source", settings.Source);
            }

            if (settings.Framework != null)
            {
                builder.AppendSwitchQuoted("--framework", settings.Framework);
            }

            if (settings.DisableParallel)
            {
                builder.Append("--disable-parallel");
            }

            if (settings.IgnoreFailedSources)
            {
                builder.Append("--ignore-failed-sources");
            }

            if (settings.NoCache)
            {
                builder.Append("--no-cache");
            }

            builder.AppendQuoted(packageId);

            return(builder);
        }
Exemplo n.º 20
0
        private ProcessArgumentBuilder GetArguments(FilePath solution, MSBuildSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            // Set the maximum number of processors?
            if (settings.MaxCpuCount != null)
            {
                builder.Append(settings.MaxCpuCount > 0 ? string.Concat("/m:", settings.MaxCpuCount) : "/m");
            }

            // Set the verbosity.
            builder.Append(string.Format(CultureInfo.InvariantCulture, "/v:{0}", GetVerbosityName(settings.Verbosity)));

            if (settings.NodeReuse != null)
            {
                builder.Append(string.Concat("/nr:", settings.NodeReuse.Value ? "true" : "false"));
            }

            // Got a specific configuration in mind?
            if (!string.IsNullOrWhiteSpace(settings.Configuration))
            {
                // Add the configuration as a property.
                builder.AppendSwitchQuoted("/p:Configuration", "=", settings.Configuration);
            }

            // Build for a specific platform?
            if (settings.PlatformTarget.HasValue)
            {
                var  platform   = settings.PlatformTarget.Value;
                bool isSolution = string.Equals(solution.GetExtension(), ".sln", StringComparison.OrdinalIgnoreCase);
                builder.Append(string.Concat("/p:Platform=", GetPlatformName(platform, isSolution)));
            }

            // Got any properties?
            if (settings.Properties.Count > 0)
            {
                foreach (var property in GetPropertyArguments(settings.Properties))
                {
                    builder.Append(property);
                }
            }

            // Got any targets?
            if (settings.Targets.Count > 0)
            {
                var targets = string.Join(";", settings.Targets);
                builder.Append(string.Concat("/target:", targets));
            }
            else
            {
                // Use default target.
                builder.Append("/target:Build");
            }

            // Add the solution as the last parameter.
            builder.AppendQuoted(solution.MakeAbsolute(_environment).FullPath);

            return(builder);
        }
 /// <summary>
 /// Quotes and appends the specified secret text to the argument builder.
 /// </summary>
 /// <param name="builder">The builder.</param>
 /// <param name="switch">The switch preceding the text.</param>
 /// <param name="separator">The separator between the switch and argument</param>
 /// <param name="argument">The secret argument to be appended.</param>
 /// <returns>The same <see cref="ProcessArgumentBuilder"/> instance so that multiple calls can be chained.</returns>
 public static ProcessArgumentBuilder AppendQuotedSecret(this ProcessArgumentBuilder builder, string @switch, string separator, IProcessArgument argument)
 {
     if (builder != null)
     {
         builder.AppendSwitchQuoted(@switch, separator, new SecretArgument(argument));
     }
     return(builder);
 }
Exemplo n.º 22
0
 internal static ProcessArgumentBuilder AppendSwitchQuoted(this ProcessArgumentBuilder builder, string @switch, IEnumerable <string> values)
 {
     foreach (var type in values.Select(s => s.Trim()))
     {
         builder.AppendSwitchQuoted(@switch, type);
     }
     return(builder);
 }
Exemplo n.º 23
0
        private ProcessArgumentBuilder GetArguments(CodeCoverageSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append(settings.command.ToString());
            builder.AppendSwitchQuoted($"/output", ":", settings.OutputPath);
            builder.AppendQuoted(settings.CoveragePath);
            return(builder);
        }
        public void Run(TerraformApplySettings settings)
        {
            var builder = new ProcessArgumentBuilder().Append("apply");

            if (!string.IsNullOrEmpty(settings.InputVariablesFile))
            {
                builder.AppendSwitchQuoted("-var-file", $"{settings.InputVariablesFile}");
            }

            if (settings.InputVariables != null)
            {
                foreach (var inputVariable in settings.InputVariables)
                {
                    builder.AppendSwitchQuoted("-var", $"{inputVariable.Key}={inputVariable.Value}");
                }
            }

            Run(settings, builder);
        }
Exemplo n.º 25
0
        private ProcessArgumentBuilder GetArguments(FilePath sourceFilePath, TextTransformSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            if (settings.OutputFile != null)
            {
                builder.Append("-out");
                builder.AppendQuoted(settings.OutputFile.MakeAbsolute(_environment).FullPath);
            }

            if (!string.IsNullOrEmpty(settings.Assembly))
            {
                builder.Append("-r");
                builder.Append(settings.Assembly);
            }

            if (!string.IsNullOrEmpty(settings.Namespace))
            {
                builder.Append("-u");
                builder.Append(settings.Namespace);
            }

            if (settings.ReferencePath != null)
            {
                builder.Append("-P");
                builder.AppendQuoted(settings.ReferencePath.MakeAbsolute(_environment).FullPath);
            }

            if (settings.IncludeDirectory != null)
            {
                builder.Append("-I");
                builder.AppendQuoted(settings.IncludeDirectory.MakeAbsolute(_environment).FullPath);
            }

            if (settings.Class != null)
            {
                builder.AppendSwitchQuoted(
                    "--class",
                    "=",
                    settings.Class);
            }

            if (settings.Properties != null)
            {
                foreach (var property in settings.Properties)
                {
                    builder.Append(
                        $"-p:{property.Key.Quote()}={property.Value.Quote()}");
                }
            }

            builder.AppendQuoted(sourceFilePath.MakeAbsolute(_environment).FullPath);

            return(builder);
        }
Exemplo n.º 26
0
 /// <inheritdoc />
 public void BuildArguments(ref ProcessArgumentBuilder builder)
 {
     if (SfxModule != null)
     {
         builder.AppendSwitchQuoted("-sfx", string.Empty, SfxModule.FullPath);
     }
     else
     {
         builder.Append("-sfx");
     }
 }
        internal override ProcessArgumentBuilder Apply(ProcessArgumentBuilder builder)
        {
            builder = base.Apply(builder);

            foreach (var kvp in Config ?? Enumerable.Empty <KeyValuePair <string, string> >())
            {
                builder.AppendSwitchQuoted("--config", $"{kvp.Key}={kvp.Value}");
            }

            return(builder);
        }
Exemplo n.º 28
0
        private ProcessArgumentBuilder GetArguments(FilePath firstInfo, FilePath secondInfo, FilePath outputPath, MonoApiDiffToolSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            builder.AppendSwitchQuoted("--output", "=", outputPath.MakeAbsolute(environment).FullPath);

            builder.AppendQuoted(firstInfo.MakeAbsolute(environment).FullPath);

            builder.AppendQuoted(secondInfo.MakeAbsolute(environment).FullPath);

            return(builder);
        }
Exemplo n.º 29
0
 internal void Evaluate(ProcessArgumentBuilder args)
 {
     if (GruntFile != null)
     {
         args.AppendSwitchQuoted("--gruntfile", GruntFile.FullPath);
     }
     if (!string.IsNullOrWhiteSpace(Arguments))
     {
         args.Append(Arguments);
     }
     EvaluateCore(args);
 }
        public void Run(TerraformDestroySettings settings)
        {
            var builder = new ProcessArgumentBuilder().Append("destroy");

            if (settings.Force)
            {
                builder = builder.Append("-force");
            }

            if (!string.IsNullOrWhiteSpace(settings.InputVariablesFile))
            {
                builder.AppendSwitchQuoted("-var-file", $"{settings.InputVariablesFile}");
            }

            foreach (var inputVariable in settings.InputVariables ?? new Dictionary <string, string>())
            {
                builder.AppendSwitchQuoted("-var", $"{inputVariable.Key}={inputVariable.Value}");
            }

            Run(settings, builder);
        }