public static void Validate(this UpdateClientCertArgs args)
        {
            if (!args.IsPackageSourceSettingProvided())
            {
                throw new CommandLineArgumentCombinationException(string.Format(CultureInfo.CurrentCulture,
                                                                                Strings.Error_PropertyCannotBeNullOrEmpty,
                                                                                nameof(PackageSource)));
            }

            if (args.IsFileCertSettingsProvided() == args.IsStoreCertSettingsProvided())
            {
                throw new CommandLineArgumentCombinationException(string.Format(CultureInfo.CurrentCulture,
                                                                                Strings.Error_CouldNotUpdateClientCertificate,
                                                                                Strings.Error_InvalidCombinationOfArguments));
            }
        }
        public static void Run(UpdateClientCertArgs args, Func <ILogger> getLogger)
        {
            args.Validate();

            var settings = RunnerHelper.GetSettings(args.Configfile);
            var clientCertificateProvider = new ClientCertificateProvider(settings);

            var item = clientCertificateProvider.GetClientCertificate(args.PackageSource);

            if (item == null)
            {
                throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                          Strings.Error_ClientCertificateNotExist,
                                                          args.PackageSource));
            }

            switch (item)
            {
            case FileClientCertItem fileCertItem:
                if (args.IsStoreCertSettingsProvided())
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                              Strings.Error_ClientCertificateTypeMismatch,
                                                              args.PackageSource));
                }

                fileCertItem.Update(args.Path, args.Password, args.StorePasswordInClearText);
                break;

            case StoreClientCertItem storeCertItem:
                if (args.IsFileCertSettingsProvided())
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture,
                                                              Strings.Error_ClientCertificateTypeMismatch,
                                                              args.PackageSource));
                }

                storeCertItem.Update(args.FindValue,
                                     args.GetStoreLocation(),
                                     args.GetStoreName(),
                                     args.GetFindBy());
                break;
            }

            try
            {
                var certificates = item.Search();
                if (!certificates.Any())
                {
                    throw new ArgumentException(string.Format(CultureInfo.CurrentCulture, Strings.Error_ClientCertificatesNotFound));
                }
            }
            catch
            {
                if (!args.Force)
                {
                    throw;
                }
            }

            clientCertificateProvider.AddOrUpdate(item);

            getLogger().LogInformation(string.Format(CultureInfo.CurrentCulture, Strings.ClientCertificateSuccessfullyUpdated, args.PackageSource));
        }