From b86e235ef4f9423624fc93e1c417484e938245df Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Wed, 24 Oct 2018 15:03:23 -0700 Subject: Re-organize command-line processing and add support for custom commands --- .../Services/ICommandLine.cs | 15 ++++++++++ .../Services/ICommandLineParser.cs | 31 ++++++++++++++++---- .../Services/IParseCommandLine.cs | 34 ---------------------- 3 files changed, 41 insertions(+), 39 deletions(-) create mode 100644 src/WixToolset.Extensibility/Services/ICommandLine.cs delete mode 100644 src/WixToolset.Extensibility/Services/IParseCommandLine.cs (limited to 'src/WixToolset.Extensibility/Services') diff --git a/src/WixToolset.Extensibility/Services/ICommandLine.cs b/src/WixToolset.Extensibility/Services/ICommandLine.cs new file mode 100644 index 00000000..48f3620f --- /dev/null +++ b/src/WixToolset.Extensibility/Services/ICommandLine.cs @@ -0,0 +1,15 @@ +// 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.Services +{ + using WixToolset.Extensibility.Data; + + public interface ICommandLine + { + IExtensionManager ExtensionManager { get; set; } + + ICommandLineArguments Arguments { get; set; } + + ICommandLineCommand ParseStandardCommandLine(); + } +} diff --git a/src/WixToolset.Extensibility/Services/ICommandLineParser.cs b/src/WixToolset.Extensibility/Services/ICommandLineParser.cs index 60507c6c..f7e2a28f 100644 --- a/src/WixToolset.Extensibility/Services/ICommandLineParser.cs +++ b/src/WixToolset.Extensibility/Services/ICommandLineParser.cs @@ -1,15 +1,36 @@ -// 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. +// 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.Services { - using WixToolset.Extensibility.Data; + using System.Collections.Generic; public interface ICommandLineParser { - IExtensionManager ExtensionManager { get; set; } + string ErrorArgument { get; set; } - ICommandLineArguments Arguments { get; set; } + /// + /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity + /// + /// The string check. + /// True if a valid switch, otherwise false. + bool IsSwitch(string arg); - ICommandLineCommand ParseStandardCommandLine(); + string GetArgumentAsFilePathOrError(string argument, string fileType); + + void GetArgumentAsFilePathOrError(string argument, string fileType, IList paths); + + string GetNextArgumentOrError(string commandLineSwitch); + + bool GetNextArgumentOrError(string commandLineSwitch, IList argument); + + string GetNextArgumentAsDirectoryOrError(string commandLineSwitch); + + bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList directories); + + string GetNextArgumentAsFilePathOrError(string commandLineSwitch); + + bool GetNextArgumentAsFilePathOrError(string commandLineSwitch, string fileType, IList paths); + + bool TryGetNextSwitchOrArgument(out string arg); } } diff --git a/src/WixToolset.Extensibility/Services/IParseCommandLine.cs b/src/WixToolset.Extensibility/Services/IParseCommandLine.cs deleted file mode 100644 index 3753b4f2..00000000 --- a/src/WixToolset.Extensibility/Services/IParseCommandLine.cs +++ /dev/null @@ -1,34 +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.Services -{ - using System.Collections.Generic; - - public interface IParseCommandLine - { - string ErrorArgument { get; set; } - - /// - /// Validates that a valid switch (starts with "/" or "-"), and returns a bool indicating its validity - /// - /// The string check. - /// True if a valid switch, otherwise false. - bool IsSwitch(string arg); - - void GetArgumentAsFilePathOrError(string argument, string fileType, IList paths); - - string GetNextArgumentOrError(string commandLineSwitch); - - bool GetNextArgumentOrError(string commandLineSwitch, IList argument); - - string GetNextArgumentAsDirectoryOrError(string commandLineSwitch); - - bool GetNextArgumentAsDirectoryOrError(string commandLineSwitch, IList directories); - - string GetNextArgumentAsFilePathOrError(string commandLineSwitch); - - bool GetNextArgumentAsFilePathOrError(string commandLineSwitch, string fileType, IList paths); - - bool TryGetNextSwitchOrArgument(out string arg); - } -} -- cgit v1.2.3-55-g6feb