Skip to content

Commit

Permalink
(chocolatey#2867) Add --online option to all commands
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gep13 committed Oct 25, 2022
1 parent bc40d1b commit 2bbacaa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,9 @@ private static void set_global_options(IList<string> 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ public static void parse_arguments_and_update_configuration(ICollection<string>

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
Expand Down

0 comments on commit 2bbacaa

Please # to comment.