From f4cefb9ac9a6911ee0a1ad035e6ee50b7f28e5c5 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Sat, 18 Jul 2020 14:55:58 -0700 Subject: Display command-line help from Core and extensions Closes wixtoolset/issues#6211 --- src/WixToolset.Core/CommandLine/HelpCommand.cs | 43 +++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'src/WixToolset.Core/CommandLine/HelpCommand.cs') diff --git a/src/WixToolset.Core/CommandLine/HelpCommand.cs b/src/WixToolset.Core/CommandLine/HelpCommand.cs index 78845189..3af442aa 100644 --- a/src/WixToolset.Core/CommandLine/HelpCommand.cs +++ b/src/WixToolset.Core/CommandLine/HelpCommand.cs @@ -3,27 +3,60 @@ namespace WixToolset.Core.CommandLine { using System; + using System.Collections.Generic; + using System.Linq; using System.Threading; using System.Threading.Tasks; + using WixToolset.Extensibility; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; internal class HelpCommand : ICommandLineCommand { + private static readonly ExtensionCommandLineSwitch[] BuiltInSwitches = new ExtensionCommandLineSwitch[] + { + new ExtensionCommandLineSwitch { Switch = "build", Description = "Build a wixlib, package or bundle." }, + new ExtensionCommandLineSwitch { Switch = "decompile", Description = "Decompile a package or bundle into source code." }, + }; + + public HelpCommand(IEnumerable extensions) + { + this.Extensions = extensions; + } + public bool ShowLogo => true; public bool StopParsing => true; + private IEnumerable Extensions { get; } + public Task ExecuteAsync(CancellationToken _) { - Console.WriteLine("TODO: Show list of available commands"); + var commandLineSwitches = new List(BuiltInSwitches); + commandLineSwitches.AddRange(this.Extensions.SelectMany(e => e.CommandLineSwitches).OrderBy(s => s.Switch, StringComparer.Ordinal)); + + Console.WriteLine(); + Console.WriteLine("Usage: wix [option]"); + Console.WriteLine("Usage: wix [command]"); + Console.WriteLine(); + Console.WriteLine("Options:"); + Console.WriteLine(" -h|--help Show command line help."); + Console.WriteLine(" --version Display WiX Toolset version in use."); + Console.WriteLine(); + + Console.WriteLine("Commands:"); + foreach (var commandLineSwitch in commandLineSwitches) + { + Console.WriteLine(" {0,-17} {1}", commandLineSwitch.Switch, commandLineSwitch.Description); + } + + Console.WriteLine(); + Console.WriteLine("Run 'wix [command] --help' for more information on a command."); + AppCommon.DisplayToolFooter(); return Task.FromResult(-1); } - public bool TryParseArgument(ICommandLineParser parseHelper, string argument) - { - return true; // eat any arguments - } + public bool TryParseArgument(ICommandLineParser parseHelper, string argument) => true; // eat any arguments } } -- cgit v1.2.3-55-g6feb