From 2bbacaa8d8c3335bc6f1b0606cabd26b82be38b6 Mon Sep 17 00:00:00 2001 From: Gary Ewan Park Date: Tue, 25 Oct 2022 21:25:31 +0000 Subject: [PATCH] (#2867) Add --online option to all commands This commit adds the --online option to all Chocolatey commands, to allow opening of the online help documentation for the command that is being executed. For example, running: choco install -h will output the help documentation to the console, but running: choco install -h --online will not output anything to the command line, and instead open the default browser to the help documentation for the command. --- .../infrastructure.app/builders/ConfigurationBuilder.cs | 3 +++ .../configuration/ChocolateyConfiguration.cs | 1 + .../configuration/ConfigurationOptions.cs | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 39877f5c57..fdfa81ea43 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -357,6 +357,9 @@ private static void set_global_options(IList args, ChocolateyConfigurati (option_set) => { option_set + .Add("online", + "Online - Open help for specified command in default browser application.", + option => config.ShowOnlineHelp = option != null) .Add("d|debug", "Debug - Show debug messaging.", option => config.Debug = option != null) diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 549ac89cb8..cb422d5ba0 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -242,6 +242,7 @@ private void append_output(StringBuilder propertyValues, string append) // top level commands + public bool ShowOnlineHelp { get; set; } public bool Debug { get; set; } public bool Verbose { get; set; } public bool Trace { get; set; } diff --git a/src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs b/src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs index 1651ba797f..69b0ef89c5 100644 --- a/src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs +++ b/src/chocolatey/infrastructure.app/configuration/ConfigurationOptions.cs @@ -120,6 +120,12 @@ public static void parse_arguments_and_update_configuration(ICollection if (configuration.HelpRequested) { + if (configuration.ShowOnlineHelp) + { + System.Diagnostics.Process.Start("explorer.exe", string.Format("https://docs.chocolatey.org/en-us/choco/commands/{0}", configuration.CommandName)); + return; + } + show_help(_optionSet, helpMessage); } else