diff options
| author | Rob Mensching <rob@firegiant.com> | 2018-07-12 21:15:17 -0700 |
|---|---|---|
| committer | Rob Mensching <rob@firegiant.com> | 2018-07-12 21:15:17 -0700 |
| commit | ce026a4a61336aec750510f501e943027e033934 (patch) | |
| tree | d2f04a9c780890ab0fe2bf4b4ab113fb157cc6f5 /src | |
| parent | 2cd75e35ba43afcb41e96f2c6aa8df44f15aa29c (diff) | |
| download | wix-ce026a4a61336aec750510f501e943027e033934.tar.gz wix-ce026a4a61336aec750510f501e943027e033934.tar.bz2 wix-ce026a4a61336aec750510f501e943027e033934.zip | |
Improve command line processing interfaces for extensions
Partial fix for wixtoolset/issues#5845
Diffstat (limited to 'src')
3 files changed, 42 insertions, 8 deletions
diff --git a/src/WixToolset.Extensibility/Services/ICommandLineArguments.cs b/src/WixToolset.Extensibility/Services/ICommandLineArguments.cs new file mode 100644 index 00000000..eb1f8765 --- /dev/null +++ b/src/WixToolset.Extensibility/Services/ICommandLineArguments.cs | |||
| @@ -0,0 +1,23 @@ | |||
| 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 | |||
| 3 | namespace WixToolset.Extensibility.Services | ||
| 4 | { | ||
| 5 | using System.Collections.Generic; | ||
| 6 | |||
| 7 | public interface ICommandLineArguments | ||
| 8 | { | ||
| 9 | string[] OriginalArguments { get; set; } | ||
| 10 | |||
| 11 | string[] Arguments { get; set; } | ||
| 12 | |||
| 13 | string[] Extensions { get; set; } | ||
| 14 | |||
| 15 | string ErrorArgument { get; set; } | ||
| 16 | |||
| 17 | void Populate(string commandLine); | ||
| 18 | |||
| 19 | void Populate(string[] args); | ||
| 20 | |||
| 21 | IParseCommandLine Parse(); | ||
| 22 | } | ||
| 23 | } | ||
diff --git a/src/WixToolset.Extensibility/Services/ICommandLineContext.cs b/src/WixToolset.Extensibility/Services/ICommandLineContext.cs index 27d4e6dd..84b9654f 100644 --- a/src/WixToolset.Extensibility/Services/ICommandLineContext.cs +++ b/src/WixToolset.Extensibility/Services/ICommandLineContext.cs | |||
| @@ -12,8 +12,6 @@ namespace WixToolset.Extensibility.Services | |||
| 12 | 12 | ||
| 13 | IExtensionManager ExtensionManager { get; set; } | 13 | IExtensionManager ExtensionManager { get; set; } |
| 14 | 14 | ||
| 15 | string Arguments { get; set; } | 15 | ICommandLineArguments Arguments { get; set; } |
| 16 | |||
| 17 | string[] ParsedArguments { get; set; } | ||
| 18 | } | 16 | } |
| 19 | } | 17 | } |
diff --git a/src/WixToolset.Extensibility/Services/IParseCommandLine.cs b/src/WixToolset.Extensibility/Services/IParseCommandLine.cs index 1b23be14..3753b4f2 100644 --- a/src/WixToolset.Extensibility/Services/IParseCommandLine.cs +++ b/src/WixToolset.Extensibility/Services/IParseCommandLine.cs | |||
| @@ -6,16 +6,29 @@ namespace WixToolset.Extensibility.Services | |||
| 6 | 6 | ||
| 7 | public interface IParseCommandLine | 7 | public interface IParseCommandLine |
| 8 | { | 8 | { |
| 9 | string ErrorArgument { get; set; } | ||
| 10 | |||
| 11 | /// <summary> | ||
| 12 | /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity | ||
| 13 | /// </summary> | ||
| 14 | /// <param name="arg">The string check.</param> | ||
| 15 | /// <returns>True if a valid switch, otherwise false.</returns> | ||
| 9 | bool IsSwitch(string arg); | 16 | bool IsSwitch(string arg); |
| 10 | 17 | ||
| 11 | bool IsSwitchAt(IEnumerable<string> args, int index); | 18 | void GetArgumentAsFilePathOrError(string argument, string fileType, IList<string> paths); |
| 19 | |||
| 20 | string GetNextArgumentOrError(string commandLineSwitch); | ||
| 21 | |||
| 22 | bool GetNextArgumentOrError(string commandLineSwitch, IList<string> argument); | ||
| 23 | |||
| 24 | string GetNextArgumentAsDirectoryOrError(string commandLineSwitch); | ||
| 12 | 25 | ||
| 13 | void GetNextArgumentOrError(ref string arg); | 26 | bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList<string> directories); |
| 14 | 27 | ||
| 15 | void GetNextArgumentOrError(IList<string> args); | 28 | string GetNextArgumentAsFilePathOrError(string commandLineSwitch); |
| 16 | 29 | ||
| 17 | void GetNextArgumentAsFilePathOrError(IList<string> args, string fileType); | 30 | bool GetNextArgumentAsFilePathOrError(string commandLineSwitch, string fileType, IList<string> paths); |
| 18 | 31 | ||
| 19 | bool TryGetNextArgumentOrError(out string arg); | 32 | bool TryGetNextSwitchOrArgument(out string arg); |
| 20 | } | 33 | } |
| 21 | } | 34 | } |
