From 70a6120723a0ffe8505ee238fbf1024f5bca3505 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Tue, 28 Feb 2017 13:19:51 -0600 Subject: [PATCH] (maint) formatting --- .../builders/ConfigurationBuilder.cs | 188 +++++++++--------- .../infrastructure.app/nuget/NugetCommon.cs | 1 - 2 files changed, 94 insertions(+), 95 deletions(-) diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index d6c07e971d..f29e9691e8 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -85,7 +85,7 @@ public static void set_up_configuration(IList args, ChocolateyConfigurat set_config_file_settings(configFileSettings, xmlService, config); set_hash_provider(config, container); } - + private static ConfigFileSettings get_config_file_settings(IFileSystem fileSystem, IXmlService xmlService) { var globalConfigPath = ApplicationParameters.GlobalConfigFileLocation; @@ -148,7 +148,7 @@ private static void set_file_configuration(ChocolateyConfiguration config, Confi if (configFileSettings.Sources.Any(s => s.Priority > 0)) { defaultSourcesInOrder = configFileSettings.Sources.Where(s => !s.Disabled && s.Priority != 0).OrderBy(s => s.Priority).or_empty_list_if_null().ToList(); - defaultSourcesInOrder.AddRange(configFileSettings.Sources.Where(s => !s.Disabled && s.Priority == 0 ).or_empty_list_if_null().ToList()); + defaultSourcesInOrder.AddRange(configFileSettings.Sources.Where(s => !s.Disabled && s.Priority == 0).or_empty_list_if_null().ToList()); } foreach (var source in defaultSourcesInOrder) @@ -228,7 +228,7 @@ private static void set_config_items(ChocolateyConfiguration config, ConfigFileS if (webRequestTimeoutSeconds <= 0) { webRequestTimeoutSeconds = ApplicationParameters.DefaultWebRequestTimeoutInSeconds; - set_config_item(ApplicationParameters.ConfigSettings.WebRequestTimeoutSeconds,configFileSettings, ApplicationParameters.DefaultWebRequestTimeoutInSeconds.to_string(),"Default timeout for web requests. Available in 0.9.10+.", forceSettingValue: true); + set_config_item(ApplicationParameters.ConfigSettings.WebRequestTimeoutSeconds, configFileSettings, ApplicationParameters.DefaultWebRequestTimeoutInSeconds.to_string(), "Default timeout for web requests. Available in 0.9.10+.", forceSettingValue: true); } config.WebRequestTimeoutSeconds = webRequestTimeoutSeconds; @@ -319,109 +319,109 @@ private static void set_global_options(IList args, ChocolateyConfigurati args, config, (option_set) => - { - option_set - .Add("d|debug", - "Debug - Show debug messaging.", - option => config.Debug = option != null) - .Add("v|verbose", - "Verbose - Show verbose messaging.", - option => config.Verbose = option != null) - .Add("acceptlicense|accept-license", - "AcceptLicense - Accept license dialogs automatically. Reserved for future use.", - option => config.AcceptLicense = option != null) - .Add("y|yes|confirm", - "Confirm all prompts - Chooses affirmative answer instead of prompting. Implies --accept-license", - option => - { - config.PromptForConfirmation = option == null; - config.AcceptLicense = option != null; - }) - .Add("f|force", - "Force - force the behavior. Do not use force during normal operation - it subverts some of the smart behavior for commands.", - option => config.Force = option != null) - .Add("noop|whatif|what-if", - "NoOp / WhatIf - Don't actually do anything.", - option => config.Noop = option != null) - .Add("r|limitoutput|limit-output", - "LimitOutput - Limit the output to essential information", - option => config.RegularOutput = option == null) - .Add("timeout=|execution-timeout=", - "CommandExecutionTimeout (in seconds) - The time to allow a command to finish before timing out. Overrides the default execution timeout in the configuration of {0} seconds.".format_with(config.CommandExecutionTimeoutSeconds.to_string()), - option => + { + option_set + .Add("d|debug", + "Debug - Show debug messaging.", + option => config.Debug = option != null) + .Add("v|verbose", + "Verbose - Show verbose messaging.", + option => config.Verbose = option != null) + .Add("acceptlicense|accept-license", + "AcceptLicense - Accept license dialogs automatically. Reserved for future use.", + option => config.AcceptLicense = option != null) + .Add("y|yes|confirm", + "Confirm all prompts - Chooses affirmative answer instead of prompting. Implies --accept-license", + option => + { + config.PromptForConfirmation = option == null; + config.AcceptLicense = option != null; + }) + .Add("f|force", + "Force - force the behavior. Do not use force during normal operation - it subverts some of the smart behavior for commands.", + option => config.Force = option != null) + .Add("noop|whatif|what-if", + "NoOp / WhatIf - Don't actually do anything.", + option => config.Noop = option != null) + .Add("r|limitoutput|limit-output", + "LimitOutput - Limit the output to essential information", + option => config.RegularOutput = option == null) + .Add("timeout=|execution-timeout=", + "CommandExecutionTimeout (in seconds) - The time to allow a command to finish before timing out. Overrides the default execution timeout in the configuration of {0} seconds.".format_with(config.CommandExecutionTimeoutSeconds.to_string()), + option => + { + int timeout = 0; + int.TryParse(option.remove_surrounding_quotes(), out timeout); + if (timeout > 0) { - int timeout = 0; - int.TryParse(option.remove_surrounding_quotes(), out timeout); - if (timeout > 0) - { - config.CommandExecutionTimeoutSeconds = timeout; - } - }) - .Add("c=|cache=|cachelocation=|cache-location=", - "CacheLocation - Location for download cache, defaults to %TEMP% or value in chocolatey.config file.", - option => config.CacheLocation = option.remove_surrounding_quotes()) - .Add("allowunofficial|allow-unofficial|allowunofficialbuild|allow-unofficial-build", - "AllowUnofficialBuild - When not using the official build you must set this flag for choco to continue.", - option => config.AllowUnofficialBuild = option != null) - .Add("failstderr|failonstderr|fail-on-stderr|fail-on-standard-error|fail-on-error-output", - "FailOnStandardError - Fail on standard error output (stderr), typically received when running external commands during install providers. This overrides the feature failOnStandardError.", - option => config.Features.FailOnStandardError = option != null) - .Add("use-system-powershell", - "UseSystemPowerShell - Execute PowerShell using an external process instead of the built-in PowerShell host. Should only be used when internal host is failing. Available in 0.9.10+.", - option => config.Features.UsePowerShellHost = option == null) - .Add("no-progress", - "Do Not Show Progress - Do not show download progress percentages. Available in 0.10.4+.", - option => config.Features.ShowDownloadProgress = option == null) - .Add("proxy=", - "Proxy Location - Explicit proxy location. Overrides the default proxy location of '{0}'. Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.".format_with(config.Proxy.Location), - option => config.Proxy.Location = option.remove_surrounding_quotes()) - .Add("proxy-user=", - "Proxy User Name - Explicit proxy user (optional). Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy user of '{0}'. Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.".format_with(config.Proxy.User), - option => config.Proxy.User = option.remove_surrounding_quotes()) - .Add("proxy-password=", - "Proxy Password - Explicit proxy password (optional) to be used with username. Requires explicity proxy (`--proxy` or config setting) and user name. Overrides the default proxy password (encrypted in settings if set). Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.", - option => config.Proxy.EncryptedPassword = NugetEncryptionUtility.EncryptString(option.remove_surrounding_quotes())) - .Add("proxy-bypass-list=", - "ProxyBypassList - Comma separated list of regex locations to bypass on proxy. Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy bypass list of '{0}'. Available in 0.10.4+.".format_with(config.Proxy.BypassList), - option => config.Proxy.BypassList = option.remove_surrounding_quotes()) - .Add("proxy-bypass-on-local", - "Proxy Bypass On Local - Bypass proxy for local connections. Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy bypass on local setting of '{0}'. Available in 0.10.4+.".format_with(config.Proxy.BypassOnLocal), - option => config.Proxy.BypassOnLocal = option != null) - ; - }, + config.CommandExecutionTimeoutSeconds = timeout; + } + }) + .Add("c=|cache=|cachelocation=|cache-location=", + "CacheLocation - Location for download cache, defaults to %TEMP% or value in chocolatey.config file.", + option => config.CacheLocation = option.remove_surrounding_quotes()) + .Add("allowunofficial|allow-unofficial|allowunofficialbuild|allow-unofficial-build", + "AllowUnofficialBuild - When not using the official build you must set this flag for choco to continue.", + option => config.AllowUnofficialBuild = option != null) + .Add("failstderr|failonstderr|fail-on-stderr|fail-on-standard-error|fail-on-error-output", + "FailOnStandardError - Fail on standard error output (stderr), typically received when running external commands during install providers. This overrides the feature failOnStandardError.", + option => config.Features.FailOnStandardError = option != null) + .Add("use-system-powershell", + "UseSystemPowerShell - Execute PowerShell using an external process instead of the built-in PowerShell host. Should only be used when internal host is failing. Available in 0.9.10+.", + option => config.Features.UsePowerShellHost = option == null) + .Add("no-progress", + "Do Not Show Progress - Do not show download progress percentages. Available in 0.10.4+.", + option => config.Features.ShowDownloadProgress = option == null) + .Add("proxy=", + "Proxy Location - Explicit proxy location. Overrides the default proxy location of '{0}'. Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.".format_with(config.Proxy.Location), + option => config.Proxy.Location = option.remove_surrounding_quotes()) + .Add("proxy-user=", + "Proxy User Name - Explicit proxy user (optional). Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy user of '{0}'. Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.".format_with(config.Proxy.User), + option => config.Proxy.User = option.remove_surrounding_quotes()) + .Add("proxy-password=", + "Proxy Password - Explicit proxy password (optional) to be used with username. Requires explicity proxy (`--proxy` or config setting) and user name. Overrides the default proxy password (encrypted in settings if set). Available for config settings in 0.9.9.9+, this CLI option available in 0.10.4+.", + option => config.Proxy.EncryptedPassword = NugetEncryptionUtility.EncryptString(option.remove_surrounding_quotes())) + .Add("proxy-bypass-list=", + "ProxyBypassList - Comma separated list of regex locations to bypass on proxy. Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy bypass list of '{0}'. Available in 0.10.4+.".format_with(config.Proxy.BypassList), + option => config.Proxy.BypassList = option.remove_surrounding_quotes()) + .Add("proxy-bypass-on-local", + "Proxy Bypass On Local - Bypass proxy for local connections. Requires explicity proxy (`--proxy` or config setting). Overrides the default proxy bypass on local setting of '{0}'. Available in 0.10.4+.".format_with(config.Proxy.BypassOnLocal), + option => config.Proxy.BypassOnLocal = option != null) + ; + }, (unparsedArgs) => + { + if (!string.IsNullOrWhiteSpace(config.CommandName)) { - if (!string.IsNullOrWhiteSpace(config.CommandName)) - { - // save help for next menu - config.HelpRequested = false; - } - }, + // save help for next menu + config.HelpRequested = false; + } + }, () => { }, () => + { + var commandsLog = new StringBuilder(); + IEnumerable commands = container.GetAllInstances(); + foreach (var command in commands.or_empty_list_if_null()) { - var commandsLog = new StringBuilder(); - IEnumerable commands = container.GetAllInstances(); - foreach (var command in commands.or_empty_list_if_null()) + var attributes = command.GetType().GetCustomAttributes(typeof(CommandForAttribute), false).Cast(); + foreach (var attribute in attributes.or_empty_list_if_null()) { - var attributes = command.GetType().GetCustomAttributes(typeof(CommandForAttribute), false).Cast(); - foreach (var attribute in attributes.or_empty_list_if_null()) - { - commandsLog.AppendFormat(" * {0} - {1}\n", attribute.CommandName, attribute.Description); - } + commandsLog.AppendFormat(" * {0} - {1}\n", attribute.CommandName, attribute.Description); } + } - "chocolatey".Log().Info(@"This is a listing of all of the different things you can pass to choco. + "chocolatey".Log().Info(@"This is a listing of all of the different things you can pass to choco. "); - "chocolatey".Log().Info(ChocolateyLoggers.Important, "Commands"); - "chocolatey".Log().Info(@" + "chocolatey".Log().Info(ChocolateyLoggers.Important, "Commands"); + "chocolatey".Log().Info(@" {0} Please run chocolatey with `choco command -help` for specific help on each command. ".format_with(commandsLog.ToString())); - "chocolatey".Log().Info(ChocolateyLoggers.Important, @"How To Pass Options / Switches"); - "chocolatey".Log().Info(@" + "chocolatey".Log().Info(ChocolateyLoggers.Important, @"How To Pass Options / Switches"); + "chocolatey".Log().Info(@" You can pass options and switches in the following ways: * Unless stated otherwise, an option/switch should only be passed one @@ -458,8 +458,8 @@ which means it should not require any special workarounds. package passed. So please split out multiple package calls when wanting to pass specific options. "); - "chocolatey".Log().Info(ChocolateyLoggers.Important, "Default Options and Switches"); - }); + "chocolatey".Log().Info(ChocolateyLoggers.Important, "Default Options and Switches"); + }); } private static void set_environment_options(ChocolateyConfiguration config) @@ -487,7 +487,7 @@ private static void set_licensed_options(ChocolateyConfiguration config, Chocola if (licensedConfigBuilder == null) { - if (config.RegularOutput) "chocolatey".Log().Warn(ChocolateyLoggers.Important, + if (config.RegularOutput) "chocolatey".Log().Warn(ChocolateyLoggers.Important, @"Unable to set licensed configuration. Please upgrade to a newer licensed version (choco upgrade chocolatey.extension)."); return; diff --git a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs index 1ff94b6310..f39edaf6c3 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetCommon.cs @@ -94,7 +94,6 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con var bypassProxy = false; if (configuration.MachineSources.Any(m => m.Name.is_equal_to(source) || m.Key.is_equal_to(source))) { - try { var machineSource = configuration.MachineSources.FirstOrDefault(m => m.Key.is_equal_to(source));