Пример #1
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);
        }
        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);
                }
            }
        }
Пример #3
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);
         }
     }
 }
Пример #4
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);
        }
        private ProcessArgumentBuilder GetArguments(OpenshiftLoginSettings settings)
        {
            var builder = new ProcessArgumentBuilder();

            builder.Append("login");

            if (!string.IsNullOrEmpty(settings.Username) && !string.IsNullOrEmpty(settings.Password))
            {
                builder.AppendSwitchQuoted("--username", "=", settings.Username);

                builder.AppendSwitchQuotedSecret("--password", "=", settings.Password);
            }
            else if (!string.IsNullOrEmpty(settings.Token))
            {
                builder.AppendSwitchQuotedSecret("--token", "=", settings.Token);
            }

            return(builder);
        }
Пример #6
0
        public void Apply(ProcessArgumentBuilder builder, string value, SonarSettings settings)
        {
            var beginSettings = settings as SonarBeginSettings;

            var version = GetVersion(beginSettings);

            if (Match(version))
            {
                if (Secure)
                {
                    builder.AppendSwitchQuotedSecret(Name, string.Empty, value);
                }
                else
                {
                    builder.AppendSwitchQuoted(Name, string.Empty, value);
                }
            }
        }
Пример #7
0
 public static ProcessArgumentBuilder AppendNonEmptySecretSwitch(this ProcessArgumentBuilder builder, string @switch, string text)
 {
     return(string.IsNullOrWhiteSpace(text) == false?builder.AppendSwitchQuotedSecret(@switch, text) : builder);
 }
Пример #8
0
 /// <inheritdoc/>
 public void BuildArguments(ref ProcessArgumentBuilder builder)
 {
     builder.AppendSwitchQuotedSecret("-p", string.Empty, password);
 }
Пример #9
0
 public ProcessArgumentBuilder BuildWindowsArguments(ProcessArgumentBuilder args)
 {
     //var args = new ProcessArgumentBuilder();
     args.Append("/Y");
     if (Pattern.IsDefined())
     {
         args.AppendSwitchQuoted("/Pattern", ":", Pattern);
     }
     if (DestinationKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/DestKey", ":", DestinationKey);
     }
     if (DestinationSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/DestSAS", ":", DestinationSAS);
     }
     if (SourceKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/SourceKey", ":", SourceKey);
     }
     if (SourceSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/SourceSAS", ":", SourceSAS);
     }
     if (Recursive)
     {
         args.Append("/S");
     }
     if (BlobType != null)
     {
         args.AppendSwitchQuoted("/BlobType", ":", BlobType.ToString());
     }
     if (UseChecksum)
     {
         args.Append("/CheckMD5");
     }
     if (LogFile != null)
     {
         args.AppendSwitchQuoted("/V", ":", LogFile.FullPath);
     }
     if (ParameterFiles.Any())
     {
         foreach (var file in ParameterFiles)
         {
             args.AppendSwitchQuoted("@", ":", file.FullPath);
         }
     }
     if (FileHandlingBehaviour != null)
     {
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ArchiveOnly))
         {
             args.Append("/A");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeNewerSource))
         {
             args.Append("/XN");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeOlderSource))
         {
             args.Append("/XO");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.UpdateLastModified))
         {
             args.Append("/MT");
         }
     }
     if (Delimiter != null)
     {
         args.AppendSwitchQuoted("/Delimiter", ":", Delimiter.ToString());
     }
     if (ConcurrentOperations != 0)
     {
         args.AppendSwitchQuoted("/NC", ":", ConcurrentOperations.ToString());
     }
     if (TargetContentType.IsDefined())
     {
         args.AppendSwitchQuoted("/SetContentType", ":", TargetContentType);
     }
     if (PayloadFormat != PayloadFormat.Default)
     {
         args.AppendSwitchQuoted("/PayloadFormat", ":", PayloadFormat.ToString());
     }
     return(args);
 }
Пример #10
0
 public ProcessArgumentBuilder BuildLinuxArguments(ProcessArgumentBuilder args)
 {
     args.Append("--quiet"); // equivalent to /Y for some reason
     if (Pattern.IsDefined())
     {
         args.AppendSwitchQuoted("--include", Pattern);
     }
     if (DestinationKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("--dest-key", DestinationKey);
     }
     if (DestinationSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("--dest-sas", DestinationSAS);
     }
     if (SourceKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("--source-key", SourceKey);
     }
     if (SourceSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("--source-sas", SourceSAS);
     }
     if (Recursive)
     {
         args.Append("--recursive");
     }
     if (BlobType != null)
     {
         args.AppendSwitch("--blob-type", BlobType.ToString().ToLower());
     }
     if (UseChecksum)
     {
         args.Append("--check-md5");
     }
     if (ParameterFiles.Any())
     {
         foreach (var file in ParameterFiles)
         {
             args.AppendSwitchQuoted("--config-file", file.FullPath);
         }
     }
     if (FileHandlingBehaviour != null)
     {
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeNewerSource))
         {
             args.Append("--exclude-newer");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeOlderSource))
         {
             args.Append("--exclude-older");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.UpdateLastModified))
         {
             args.Append("--preserve-last-modified-time");
         }
     }
     if (Delimiter != null)
     {
         args.AppendSwitchQuoted("--delimiter", Delimiter.ToString());
     }
     if (ConcurrentOperations != 0)
     {
         args.AppendSwitchQuoted("--parallel-level", ConcurrentOperations.ToString());
     }
     if (TargetContentType.IsDefined())
     {
         args.AppendSwitchQuoted("--set-content-type", TargetContentType);
     }
     return(args);
 }
Пример #11
0
 public ProcessArgumentBuilder BuildWindowsArguments(ProcessArgumentBuilder args)
 {
     //var args = new ProcessArgumentBuilder();
     args.Append("/Y");
     if (Pattern.IsDefined())
     {
         args.AppendSwitchQuoted("/Pattern", ":", Pattern);
     }
     if (DestinationKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/DestKey", ":", DestinationKey);
     }
     if (DestinationSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/DestSAS", ":", DestinationSAS);
     }
     if (SourceKey.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/SourceKey", ":", SourceKey);
     }
     if (SourceSAS.IsDefined())
     {
         args.AppendSwitchQuotedSecret("/SourceSAS", ":", SourceSAS);
     }
     if (Recursive)
     {
         args.Append("/S");
     }
     if (BlobType != null)
     {
         args.AppendSwitchQuoted("/BlobType", ":", BlobType.ToString());
     }
     if (UseChecksum)
     {
         args.Append("/CheckMD5");
     }
     if (LogFile != null)
     {
         args.AppendSwitchQuoted("/V", ":", LogFile.FullPath);
     }
     if (ParameterFiles.Any())
     {
         foreach (var file in ParameterFiles)
         {
             args.AppendSwitchQuoted("@", ":", file.FullPath);
         }
     }
     if (FileHandlingBehaviour != null)
     {
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ArchiveOnly))
         {
             args.Append("/A");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeNewerSource))
         {
             args.Append("/XN");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeOlderSource))
         {
             args.Append("/XO");
         }
         if (FileHandlingBehaviour.Value.HasFlag(FileHandling.UpdateLastModified))
         {
             args.Append("/MT");
         }
     }
     if (Delimiter != null)
     {
         args.AppendSwitchQuoted("/Delimiter", ":", Delimiter.ToString());
     }
     if (ConcurrentOperations != 0)
     {
         args.AppendSwitchQuoted("/NC", ":", ConcurrentOperations.ToString());
     }
     if (TargetContentType != null)
     {
         // Could be present but empty
         if (TargetContentType.Equals(String.Empty))
         {
             // If you specify this option without a value, then AzCopy sets each blob or file's content type according to its file extension.
             // https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy#setcontenttypecontent-type
             args.AppendSwitchQuoted("/SetContentType", String.Empty);
         }
         else
         {
             args.AppendSwitchQuoted("/SetContentType", ":", TargetContentType);
         }
     }
     if (PayloadFormat != PayloadFormat.Default)
     {
         args.AppendSwitchQuoted("/PayloadFormat", ":", PayloadFormat.ToString());
     }
     return(args);
 }
Пример #12
0
        public ProcessArgumentBuilder BuildLinuxArguments(ProcessArgumentBuilder args)
        {
            args.Append("--quiet"); // equivalent to /Y for some reason
            if (Pattern.IsDefined())
            {
                args.AppendSwitchQuoted("--include", Pattern);
            }
            if (DestinationKey.IsDefined())
            {
                args.AppendSwitchQuotedSecret("--dest-key", DestinationKey);
            }
            if (DestinationSAS.IsDefined())
            {
                args.AppendSwitchQuotedSecret("--dest-sas", DestinationSAS);
            }
            if (SourceKey.IsDefined())
            {
                args.AppendSwitchQuotedSecret("--source-key", SourceKey);
            }
            if (SourceSAS.IsDefined())
            {
                args.AppendSwitchQuotedSecret("--source-sas", SourceSAS);
            }
            if (Recursive)
            {
                args.Append("--recursive");
            }
            if (BlobType != null)
            {
                args.AppendSwitch("--blob-type", BlobType.ToString().ToLower());
            }
            if (UseChecksum)
            {
                args.Append("--check-md5");
            }
            if (ParameterFiles.Any())
            {
                foreach (var file in ParameterFiles)
                {
                    args.AppendSwitchQuoted("--config-file", file.FullPath);
                }
            }
            if (FileHandlingBehaviour != null)
            {
                if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeNewerSource))
                {
                    args.Append("--exclude-newer");
                }
                if (FileHandlingBehaviour.Value.HasFlag(FileHandling.ExcludeOlderSource))
                {
                    args.Append("--exclude-older");
                }
                if (FileHandlingBehaviour.Value.HasFlag(FileHandling.UpdateLastModified))
                {
                    args.Append("--preserve-last-modified-time");
                }
            }
            if (Delimiter != null)
            {
                args.AppendSwitchQuoted("--delimiter", Delimiter.ToString());
            }
            if (ConcurrentOperations != 0)
            {
                args.AppendSwitchQuoted("--parallel-level", ConcurrentOperations.ToString());
            }

            if (TargetContentType != null)
            {
                // Could be present but empty
                if (TargetContentType.Equals(String.Empty))
                {
                    // If you specify this option without a value, then AzCopy sets each blob or file's content type according to its file extension.
                    // https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy#setcontenttypecontent-type
                    args.AppendSwitchQuoted("--set-content-type", String.Empty);
                }
                else
                {
                    args.AppendSwitchQuoted("--set-content-type", TargetContentType);
                }
            }

            return(args);
        }