aboutsummaryrefslogtreecommitdiff
path: root/src/api
diff options
context:
space:
mode:
authorRob Mensching <rob@firegiant.com>2022-08-11 17:40:06 -0700
committerRob Mensching <rob@firegiant.com>2022-08-15 06:49:36 -0700
commita6f8b6fa3903d846cdc2fbe715ca951d83af3107 (patch)
treee1c554fc6c386c5dc881d288661aa0d1ba0a84a4 /src/api
parent4a21abbfc4d3b18bda3547a6c792be9f21df356e (diff)
downloadwix-a6f8b6fa3903d846cdc2fbe715ca951d83af3107.tar.gz
wix-a6f8b6fa3903d846cdc2fbe715ca951d83af3107.tar.bz2
wix-a6f8b6fa3903d846cdc2fbe715ca951d83af3107.zip
Redesign command-line help to meet the needs of WiX v4
Diffstat (limited to 'src/api')
-rw-r--r--src/api/wix/WixToolset.Extensibility/BaseCommandLineCommand.cs40
-rw-r--r--src/api/wix/WixToolset.Extensibility/BaseExtensionCommandLine.cs9
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/CommandLineHelp.cs52
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpCommand.cs31
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/CommandLineHelpSwitch.cs47
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/ExtensionCommandLineSwitch.cs20
-rw-r--r--src/api/wix/WixToolset.Extensibility/Data/ICommandLineCommand.cs12
-rw-r--r--src/api/wix/WixToolset.Extensibility/IExtensionCommandLine.cs6
8 files changed, 183 insertions, 34 deletions
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 @@
1// 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.
2
3namespace WixToolset.Extensibility
4{
5 using System.Threading;
6 using System.Threading.Tasks;
7 using WixToolset.Extensibility.Data;
8 using WixToolset.Extensibility.Services;
9
10 /// <summary>
11 /// Base class for a command-line command.
12 /// </summary>
13 public abstract class BaseCommandLineCommand : ICommandLineCommand
14 {
15 /// <summary>
16 /// See <see cref="ICommandLineCommand.ShowLogo" />
17 /// </summary>
18 public virtual bool ShowLogo => false;
19
20 /// <summary>
21 /// See <see cref="ICommandLineCommand.StopParsing" />
22 /// </summary>
23 public bool StopParsing { get; protected set; }
24
25 /// <summary>
26 /// See <see cref="ICommandLineCommand.ExecuteAsync" />
27 /// </summary>
28 public abstract Task<int> ExecuteAsync(CancellationToken cancellationToken);
29
30 /// <summary>
31 /// See <see cref="ICommandLineCommand.GetCommandLineHelp" />
32 /// </summary>
33 public abstract CommandLineHelp GetCommandLineHelp();
34
35 /// <summary>
36 /// See <see cref="ICommandLineCommand.TryParseArgument" />
37 /// </summary>
38 public abstract bool TryParseArgument(ICommandLineParser parser, string argument);
39 }
40}
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 @@
2 2
3namespace WixToolset.Extensibility 3namespace WixToolset.Extensibility
4{ 4{
5 using System;
6 using System.Collections.Generic;
7 using WixToolset.Extensibility.Data; 5 using WixToolset.Extensibility.Data;
8 using WixToolset.Extensibility.Services; 6 using WixToolset.Extensibility.Services;
9 7
@@ -13,9 +11,12 @@ namespace WixToolset.Extensibility
13 public abstract class BaseExtensionCommandLine : IExtensionCommandLine 11 public abstract class BaseExtensionCommandLine : IExtensionCommandLine
14 { 12 {
15 /// <summary> 13 /// <summary>
16 /// See <see cref="IExtensionCommandLine.CommandLineSwitches" /> 14 /// See <see cref="IExtensionCommandLine.GetCommandLineHelp" />
17 /// </summary> 15 /// </summary>
18 public virtual IReadOnlyCollection<ExtensionCommandLineSwitch> CommandLineSwitches => Array.Empty<ExtensionCommandLineSwitch>(); 16 public virtual CommandLineHelp GetCommandLineHelp()
17 {
18 return null;
19 }
19 20
20 /// <summary> 21 /// <summary>
21 /// See <see cref="IExtensionCommandLine.PostParse" /> 22 /// See <see cref="IExtensionCommandLine.PostParse" />
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 @@
1// 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.
2
3namespace WixToolset.Extensibility.Data
4{
5 using System.Collections.Generic;
6
7 /// <summary>
8 /// A command line option (switch or command) description.
9 /// </summary>
10 public class CommandLineHelp
11 {
12 /// <summary>
13 /// Creates command line help.
14 /// </summary>
15 /// <param name="description">Description for the command line option.</param>
16 /// <param name="usage">Optional usage for the command line option.</param>
17 /// <param name="switches">Optional list of switches.</param>
18 /// <param name="commands">Optional list of commands.</param>
19 public CommandLineHelp(string description, string usage = null, IReadOnlyCollection<CommandLineHelpSwitch> switches = null, IReadOnlyCollection<CommandLineHelpCommand> commands = null)
20 {
21 this.Description = description;
22 this.Usage = usage;
23 this.Switches = switches;
24 this.Commands = commands;
25 }
26
27 /// <summary>
28 /// Description for the command line option.
29 /// </summary>
30 public string Description { get; set; }
31
32 /// <summary>
33 /// Usage for the command line option.
34 /// </summary>
35 public string Usage { get; set; }
36
37 /// <summary>
38 /// Optional additional notes for the command line option.
39 /// </summary>
40 public string Notes { get; set; }
41
42 /// <summary>
43 /// Optional list of command line switches.
44 /// </summary>
45 public IReadOnlyCollection<CommandLineHelpSwitch> Switches { get; set; }
46
47 /// <summary>
48 /// Optional list of command line commands.
49 /// </summary>
50 public IReadOnlyCollection<CommandLineHelpCommand> Commands { get; set; }
51 }
52}
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 @@
1// 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.
2
3namespace WixToolset.Extensibility.Data
4{
5 /// <summary>
6 /// A command line command description.
7 /// </summary>
8 public class CommandLineHelpCommand
9 {
10 /// <summary>
11 /// Creates help for command line command.
12 /// </summary>
13 /// <param name="name">Name of command.</param>
14 /// <param name="description">Description for command.</param>
15 public CommandLineHelpCommand(string name, string description)
16 {
17 Name = name;
18 Description = description;
19 }
20
21 /// <summary>
22 /// Name of command.
23 /// </summary>
24 public string Name { get; set; }
25
26 /// <summary>
27 /// Description of the command.
28 /// </summary>
29 public string Description { get; set; }
30 }
31}
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 @@
1// 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.
2
3namespace WixToolset.Extensibility.Data
4{
5 /// <summary>
6 /// A command line switch description.
7 /// </summary>
8 public class CommandLineHelpSwitch
9 {
10 /// <summary>
11 /// Creates help for command line switch.
12 /// </summary>
13 /// <param name="name">Name of switch.</param>
14 /// <param name="description">Description for switch.</param>
15 public CommandLineHelpSwitch(string name, string description) : this(name, null, description)
16 {
17 }
18
19 /// <summary>
20 /// Creates help for command line switch.
21 /// </summary>
22 /// <param name="name">Name of switch.</param>
23 /// <param name="shortName">Optional short name of switch.</param>
24 /// <param name="description">Description for switch.</param>
25 public CommandLineHelpSwitch(string name, string shortName, string description)
26 {
27 Name = name;
28 ShortName = shortName;
29 Description = description;
30 }
31
32 /// <summary>
33 /// Name for switch.
34 /// </summary>
35 public string Name { get; set; }
36
37 /// <summary>
38 /// Optional short name for switch.
39 /// </summary>
40 public string ShortName { get; set; }
41
42 /// <summary>
43 /// Description of the switch.
44 /// </summary>
45 public string Description { get; set; }
46 }
47}
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 @@
1// 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.
2
3namespace WixToolset.Extensibility.Data
4{
5 /// <summary>
6 /// A command line option.
7 /// </summary>
8 public struct ExtensionCommandLineSwitch
9 {
10 /// <summary>
11 ///
12 /// </summary>
13 public string Switch { get; set; }
14
15 /// <summary>
16 ///
17 /// </summary>
18 public string Description { get; set; }
19 }
20}
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
12 public interface ICommandLineCommand 12 public interface ICommandLineCommand
13 { 13 {
14 /// <summary> 14 /// <summary>
15 /// Indicates the command-line should show help for the command. 15 /// Indicates the command-line should show the logo.
16 /// </summary> 16 /// </summary>
17 bool ShowHelp { get; set; } 17 bool ShowLogo { get; }
18 18
19 /// <summary> 19 /// <summary>
20 /// Indicates the command-line should show the command-line logo. 20 /// Indicates the command-line parsing can stop.
21 /// </summary> 21 /// </summary>
22 bool ShowLogo { get; set; } 22 bool StopParsing { get; }
23 23
24 /// <summary> 24 /// <summary>
25 /// Indicates the command-line parsing can stop. 25 /// Gets the help for this command.
26 /// </summary> 26 /// </summary>
27 bool StopParsing { get; } 27 CommandLineHelp GetCommandLineHelp();
28 28
29 /// <summary> 29 /// <summary>
30 /// Executes the command. 30 /// 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 @@
2 2
3namespace WixToolset.Extensibility 3namespace WixToolset.Extensibility
4{ 4{
5 using System.Collections.Generic;
6 using WixToolset.Extensibility.Data; 5 using WixToolset.Extensibility.Data;
7 using WixToolset.Extensibility.Services; 6 using WixToolset.Extensibility.Services;
8 7
@@ -12,10 +11,9 @@ namespace WixToolset.Extensibility
12 public interface IExtensionCommandLine 11 public interface IExtensionCommandLine
13 { 12 {
14 /// <summary> 13 /// <summary>
15 /// Gets the supported command line types for this extension. 14 /// Gets the help for this extension.
16 /// </summary> 15 /// </summary>
17 /// <value>The supported command line types for this extension.</value> 16 CommandLineHelp GetCommandLineHelp();
18 IReadOnlyCollection<ExtensionCommandLineSwitch> CommandLineSwitches { get; }
19 17
20 /// <summary> 18 /// <summary>
21 /// Called before the command-line is parsed. 19 /// Called before the command-line is parsed.