From a6f8b6fa3903d846cdc2fbe715ca951d83af3107 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 11 Aug 2022 17:40:06 -0700 Subject: Redesign command-line help to meet the needs of WiX v4 --- .../BaseCommandLineCommand.cs | 40 +++++++++++++++++ .../BaseExtensionCommandLine.cs | 9 ++-- .../Data/CommandLineHelp.cs | 52 ++++++++++++++++++++++ .../Data/CommandLineHelpCommand.cs | 31 +++++++++++++ .../Data/CommandLineHelpSwitch.cs | 47 +++++++++++++++++++ .../Data/ExtensionCommandLineSwitch.cs | 20 --------- .../Data/ICommandLineCommand.cs | 12 ++--- .../IExtensionCommandLine.cs | 6 +-- 8 files changed, 183 insertions(+), 34 deletions(-) create mode 100644 src/api/wix/WixToolset.Extensibility/BaseCommandLineCommand.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/CommandLineHelp.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpCommand.cs create mode 100644 src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpSwitch.cs delete mode 100644 src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs (limited to 'src/api') diff --git a/src/api/wix/WixToolset.Extensibility/BaseCommandLineCommand.cs b/src/api/wix/WixToolset.Extensibility/BaseCommandLineCommand.cs new file mode 100644 index 00000000..69a4f49f --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/BaseCommandLineCommand.cs @@ -0,0 +1,40 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility +{ + using System.Threading; + using System.Threading.Tasks; + using WixToolset.Extensibility.Data; + using WixToolset.Extensibility.Services; + + /// + /// Base class for a command-line command. + /// + public abstract class BaseCommandLineCommand : ICommandLineCommand + { + /// + /// See + /// + public virtual bool ShowLogo => false; + + /// + /// See + /// + public bool StopParsing { get; protected set; } + + /// + /// See + /// + public abstract Task ExecuteAsync(CancellationToken cancellationToken); + + /// + /// See + /// + public abstract CommandLineHelp GetCommandLineHelp(); + + /// + /// See + /// + public abstract bool TryParseArgument(ICommandLineParser parser, string argument); + } +} diff --git a/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs b/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs index c716ac7e..2690788b 100644 --- a/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs +++ b/src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs @@ -2,8 +2,6 @@ namespace WixToolset.Extensibility { - using System; - using System.Collections.Generic; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -13,9 +11,12 @@ namespace WixToolset.Extensibility public abstract class BaseExtensionCommandLine : IExtensionCommandLine { /// - /// See + /// See /// - public virtual IReadOnlyCollection CommandLineSwitches => Array.Empty(); + public virtual CommandLineHelp GetCommandLineHelp() + { + return null; + } /// /// See diff --git a/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelp.cs b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelp.cs new file mode 100644 index 00000000..52291947 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelp.cs @@ -0,0 +1,52 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Data +{ + using System.Collections.Generic; + + /// + /// A command line option (switch or command) description. + /// + public class CommandLineHelp + { + /// + /// Creates command line help. + /// + /// Description for the command line option. + /// Optional usage for the command line option. + /// Optional list of switches. + /// Optional list of commands. + public CommandLineHelp(string description, string usage = null, IReadOnlyCollection switches = null, IReadOnlyCollection commands = null) + { + this.Description = description; + this.Usage = usage; + this.Switches = switches; + this.Commands = commands; + } + + /// + /// Description for the command line option. + /// + public string Description { get; set; } + + /// + /// Usage for the command line option. + /// + public string Usage { get; set; } + + /// + /// Optional additional notes for the command line option. + /// + public string Notes { get; set; } + + /// + /// Optional list of command line switches. + /// + public IReadOnlyCollection Switches { get; set; } + + /// + /// Optional list of command line commands. + /// + public IReadOnlyCollection Commands { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpCommand.cs b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpCommand.cs new file mode 100644 index 00000000..a9fc70f9 --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpCommand.cs @@ -0,0 +1,31 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Data +{ + /// + /// A command line command description. + /// + public class CommandLineHelpCommand + { + /// + /// Creates help for command line command. + /// + /// Name of command. + /// Description for command. + public CommandLineHelpCommand(string name, string description) + { + Name = name; + Description = description; + } + + /// + /// Name of command. + /// + public string Name { get; set; } + + /// + /// Description of the command. + /// + public string Description { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpSwitch.cs b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpSwitch.cs new file mode 100644 index 00000000..19c014ad --- /dev/null +++ b/src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpSwitch.cs @@ -0,0 +1,47 @@ +// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. + +namespace WixToolset.Extensibility.Data +{ + /// + /// A command line switch description. + /// + public class CommandLineHelpSwitch + { + /// + /// Creates help for command line switch. + /// + /// Name of switch. + /// Description for switch. + public CommandLineHelpSwitch(string name, string description) : this(name, null, description) + { + } + + /// + /// Creates help for command line switch. + /// + /// Name of switch. + /// Optional short name of switch. + /// Description for switch. + public CommandLineHelpSwitch(string name, string shortName, string description) + { + Name = name; + ShortName = shortName; + Description = description; + } + + /// + /// Name for switch. + /// + public string Name { get; set; } + + /// + /// Optional short name for switch. + /// + public string ShortName { get; set; } + + /// + /// Description of the switch. + /// + public string Description { get; set; } + } +} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs b/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs deleted file mode 100644 index 14b5dabb..00000000 --- a/src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. - -namespace WixToolset.Extensibility.Data -{ - /// - /// A command line option. - /// - public struct ExtensionCommandLineSwitch - { - /// - /// - /// - public string Switch { get; set; } - - /// - /// - /// - public string Description { get; set; } - } -} diff --git a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs index b6c9ef3e..1f58bfb5 100644 --- a/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs +++ b/src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs @@ -12,19 +12,19 @@ namespace WixToolset.Extensibility.Data public interface ICommandLineCommand { /// - /// Indicates the command-line should show help for the command. + /// Indicates the command-line should show the logo. /// - bool ShowHelp { get; set; } + bool ShowLogo { get; } /// - /// Indicates the command-line should show the command-line logo. + /// Indicates the command-line parsing can stop. /// - bool ShowLogo { get; set; } + bool StopParsing { get; } /// - /// Indicates the command-line parsing can stop. + /// Gets the help for this command. /// - bool StopParsing { get; } + CommandLineHelp GetCommandLineHelp(); /// /// Executes the command. diff --git a/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs b/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs index f7b19955..304c30bb 100644 --- a/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs +++ b/src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs @@ -2,7 +2,6 @@ namespace WixToolset.Extensibility { - using System.Collections.Generic; using WixToolset.Extensibility.Data; using WixToolset.Extensibility.Services; @@ -12,10 +11,9 @@ namespace WixToolset.Extensibility public interface IExtensionCommandLine { /// - /// Gets the supported command line types for this extension. + /// Gets the help for this extension. /// - /// The supported command line types for this extension. - IReadOnlyCollection CommandLineSwitches { get; } + CommandLineHelp GetCommandLineHelp(); /// /// Called before the command-line is parsed. -- cgit v1.2.3-55-g6feb