public virtual void run(ChocolateyConfiguration configuration)
        {
            if (configuration.ApiKeyCommand.Remove)
            {
                _configSettingsService.remove_api_key(configuration);
            }
            else if (string.IsNullOrWhiteSpace(configuration.ApiKeyCommand.Key))
            {
                _configSettingsService.get_api_key(configuration, (key) =>
                {
                    string authenticatedString = string.IsNullOrWhiteSpace(key.Key) ? string.Empty : "(Authenticated)";

                    if (configuration.RegularOutput)
                    {
                        this.Log().Info(() => "{0} - {1}".format_with(key.Source, authenticatedString));
                    }
                    else
                    {
                        this.Log().Info(() => "{0}|{1}".format_with(key.Source, authenticatedString));
                    }
                });
            }
            else
            {
                _configSettingsService.set_api_key(configuration);
            }
        }
Esempio n. 2
0
        public virtual void handle_additional_argument_parsing(IList <string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            configuration.Input = string.Join(" ", unparsedArguments); // path to .nupkg - assume relative

            if (string.IsNullOrWhiteSpace(configuration.Sources))
            {
                configuration.Sources = ApplicationParameters.ChocolateyCommunityFeedPushSource;
                var newSourceKey = _configSettingsService.get_api_key(configuration, null);

                if (string.IsNullOrWhiteSpace(newSourceKey))
                {
                    configuration.Sources = ApplicationParameters.ChocolateyCommunityFeedPushSourceOld;
                    var oldSourceKey = _configSettingsService.get_api_key(configuration, null);

                    if (string.IsNullOrWhiteSpace(oldSourceKey))
                    {
                        configuration.Sources = ApplicationParameters.ChocolateyCommunityFeedPushSource;
                    }
                    else
                    {
                        this.Log().Warn(ChocolateyLoggers.Important, @"ACTION: Please update your apikey to use 
  '{0}' 
 instead of 
  '{1}'. 
 The latter source url is now considered deprecated and will not be 
 checked as the default source in Chocolatey v1.0. For details, run 
 `choco apikey -?`".format_with(ApplicationParameters.ChocolateyCommunityFeedPushSource, ApplicationParameters.ChocolateyCommunityFeedPushSourceOld));
                    }
                }
            }

            if (!string.IsNullOrWhiteSpace(configuration.Sources))
            {
                var remoteSource = new Uri(configuration.Sources);
                if (string.IsNullOrWhiteSpace(configuration.PushCommand.Key) && !remoteSource.IsUnc && !remoteSource.IsFile)
                {
                    // perform a lookup
                    configuration.PushCommand.Key = _configSettingsService.get_api_key(configuration, null);
                }
            }
        }
Esempio n. 3
0
        public void handle_additional_argument_parsing(IList <string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            configuration.Input = string.Join(" ", unparsedArguments); // path to .nupkg - assume relative

            if (!string.IsNullOrWhiteSpace(configuration.Sources))
            {
                var remoteSource = new Uri(configuration.Sources);
                if (string.IsNullOrWhiteSpace(configuration.PushCommand.Key) && !remoteSource.IsUnc && !remoteSource.IsFile)
                {
                    // perform a lookup
                    configuration.PushCommand.Key = _configSettingsService.get_api_key(configuration, null);
                }
            }
        }
Esempio n. 4
0
        public virtual void handle_additional_argument_parsing(IList <string> unparsedArguments, ChocolateyConfiguration configuration)
        {
            configuration.Input                   = string.Join(" ", unparsedArguments); // name of package to ID
            configuration.ListCommand.Exact       = true;
            configuration.SkipMissingDependencies = true;

            if (!string.IsNullOrWhiteSpace(configuration.Sources))
            {
                var remoteSource = new Uri(configuration.Sources);
                if (string.IsNullOrWhiteSpace(configuration.PushCommand.Key) && !remoteSource.IsUnc && !remoteSource.IsFile)
                {
                    // perform a lookup
                    configuration.PushCommand.Key = _configSettingsService.get_api_key(configuration, null);
                }
            }
        }
Esempio n. 5
0
 public void run(ChocolateyConfiguration configuration)
 {
     if (string.IsNullOrWhiteSpace(configuration.ApiKeyCommand.Key))
     {
         _configSettingsService.get_api_key(configuration, (key) =>
         {
             if (configuration.RegularOuptut)
             {
                 this.Log().Info(() => "{0} - {1}".format_with(key.Source, key.Key));
             }
             else
             {
                 this.Log().Info(() => "{0}|{1}".format_with(key.Source, key.Key));
             }
         });
     }
     else
     {
         _configSettingsService.set_api_key(configuration);
     }
 }