diff --git a/FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.csproj b/FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.csproj
index 433c379..db00166 100644
--- a/FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.csproj
+++ b/FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.csproj
@@ -15,6 +15,7 @@
..\
+ true
true
@@ -151,12 +152,6 @@
-
-
- {74CDFA61-81D8-40F2-B536-949BABA15D3E}
- FluentCommandLineParser
-
-
@@ -167,7 +162,14 @@
Designer
+
+
+ {0fbc96d2-68f6-4a40-9182-37265883e5bd}
+ FluentCommandLineParserPortable
+
+
+
+
\ No newline at end of file
diff --git a/FluentCommandLineParser/ICommandLineParserResult.cs b/FluentCommandLineParser/ICommandLineParserResult.cs
index 7258dd8..2e32b94 100644
--- a/FluentCommandLineParser/ICommandLineParserResult.cs
+++ b/FluentCommandLineParser/ICommandLineParserResult.cs
@@ -66,5 +66,10 @@ public interface ICommandLineParserResult
/// Contains all the setup options that were not matched during the parse operation.
///
IEnumerable UnMatchedOptions { get; }
+
+ ///
+ /// Contains all arguments that could not be matched to any option
+ ///
+ IEnumerable UnMatchedArgs { get; }
}
}
diff --git a/FluentCommandLineParser/Internals/CommandLineOption.cs b/FluentCommandLineParser/Internals/CommandLineOption.cs
index ca8a077..4e287b9 100644
--- a/FluentCommandLineParser/Internals/CommandLineOption.cs
+++ b/FluentCommandLineParser/Internals/CommandLineOption.cs
@@ -150,13 +150,14 @@ public bool HasAdditionalArgumentsCallback
/// Binds the specified to the Option.
///
/// The to bind.
- public void Bind(ParsedOption value)
+ public IEnumerable Bind(ParsedOption value)
{
if (this.Parser.CanParse(value) == false) throw new OptionSyntaxException();
+ var parseRes = this.Parser.Parse(value);
+ this.Bind(parseRes.ParsedValue);
+ this.BindAnyAdditionalArgs(value);
- this.Bind(this.Parser.Parse(value));
-
- this.BindAnyAdditionalArgs(value);
+ return parseRes.UnMatchedValues;
}
///
diff --git a/FluentCommandLineParser/Internals/Extensions/UsefulExtension.cs b/FluentCommandLineParser/Internals/Extensions/UsefulExtension.cs
index 31796a4..46beed5 100644
--- a/FluentCommandLineParser/Internals/Extensions/UsefulExtension.cs
+++ b/FluentCommandLineParser/Internals/Extensions/UsefulExtension.cs
@@ -118,26 +118,53 @@ public static bool IsWrappedInDoubleQuotes(this string str)
return str.IsNullOrWhiteSpace() == false && str.StartsWith("\"") && str.EndsWith("\"");
}
+ ///
+ /// permet de parser une chaine contenant les arguments
+ ///
+ ///
+ ///
+ public static string[] ParseArguments(this string args)
+ {
+ args = ReplaceWithDoubleQuotes(args);
+ return args.SplitOnWhitespace().ToArray();
+ }
+
+ private static string ReplaceWithDoubleQuotes(string args)
+ {
+ if (args == null) return null;
+ return args.Replace('\'', '"');
+ }
+
///
/// Splits the specified when each whitespace char is encountered into a collection of substrings.
///
/// The to split.
/// A collection of substrings taken from .
- /// If the whitespace is wrapped in double quotes then it is ignored.
+ /// If the whitespace is wrapped in double quotes or quotes then it is ignored.
public static IEnumerable SplitOnWhitespace(this string value)
{
- if (string.IsNullOrEmpty(value)) return null;
+ if (string.IsNullOrEmpty(value)) return Enumerable.Empty();
char[] parmChars = value.ToCharArray();
- bool inDoubleQuotes = false;
+ //checking if we are between quotes (simple or double)
+ bool inDblQuotes = false;
+ bool inSmplQuote = false;
for (int index = 0; index < parmChars.Length; index++)
{
- if (parmChars[index] == '"')
- inDoubleQuotes = !inDoubleQuotes;
-
- if (!inDoubleQuotes && parmChars[index] == ' ')
+ if (parmChars[index] == '"')
+ {
+ inDblQuotes = !inDblQuotes;
+ }
+ else if (parmChars[index] == '\'')
+ {
+ inSmplQuote = !inSmplQuote;
+ }
+
+ bool inQuotes = inDblQuotes || inSmplQuote;
+
+ if (!inQuotes && parmChars[index] == ' ')
parmChars[index] = '\n';
}
diff --git a/FluentCommandLineParser/Internals/ICommandLineOption.cs b/FluentCommandLineParser/Internals/ICommandLineOption.cs
index 5ee6563..8c8c9bf 100644
--- a/FluentCommandLineParser/Internals/ICommandLineOption.cs
+++ b/FluentCommandLineParser/Internals/ICommandLineOption.cs
@@ -23,6 +23,7 @@
#endregion
using System;
+using System.Collections.Generic;
using Fclp.Internals.Parsing;
namespace Fclp.Internals
@@ -46,7 +47,8 @@ public interface ICommandLineOption
/// Binds the specified to this .
///
/// The to bind.
- void Bind(ParsedOption value);
+ /// the unmatched values
+ IEnumerable Bind(ParsedOption value);
///
/// Binds the default value for this if available.
diff --git a/FluentCommandLineParser/Internals/Parsing/CommandLineOptionGrouper.cs b/FluentCommandLineParser/Internals/Parsing/CommandLineOptionGrouper.cs
index 5884968..afc78f0 100644
--- a/FluentCommandLineParser/Internals/Parsing/CommandLineOptionGrouper.cs
+++ b/FluentCommandLineParser/Internals/Parsing/CommandLineOptionGrouper.cs
@@ -26,6 +26,7 @@
using System.Collections.Generic;
using System.Linq;
using Fclp.Internals.Extensions;
+using FluentCommandLineParser.Internals.Parsing;
namespace Fclp.Internals.Parsing
{
@@ -37,16 +38,19 @@ public class CommandLineOptionGrouper
private string[] _args;
private int _currentOptionLookupIndex;
private int[] _foundOptionLookup;
+ //lookup indexed by arg id which indicates if arg is matched into an option
+ private bool[] _matchedArgsLookup;
private int _currentOptionIndex;
///
/// Groups the specified arguments by the associated Option.
///
- public string[][] GroupArgumentsByOption(string[] args)
+ public GroupArgumentsByOptionResult GroupArgumentsByOption(string[] args)
{
- if (args.IsNullOrEmpty()) return new string[0][];
+ if (args.IsNullOrEmpty()) return new GroupArgumentsByOptionResult(new string[0][], new string[0]);
_args = args;
+ _matchedArgsLookup = new bool[args.Length];
_currentOptionIndex = -1;
_currentOptionLookupIndex = -1;
@@ -54,11 +58,7 @@ public string[][] GroupArgumentsByOption(string[] args)
var options = new List();
- if (this.ArgsContainsOptions() == false)
- {
- options.Add(this.CreateGroupForCurrent());
- }
- else
+ if (this.ArgsContainsOptions())
{
while (MoveToNextOption())
{
@@ -66,7 +66,10 @@ public string[][] GroupArgumentsByOption(string[] args)
}
}
- return options.ToArray();
+ var unmatchedArgs = args.Where((arg, argIdx) => !_matchedArgsLookup[argIdx])
+ .Where(arg=>!IsEndOfOptionsKey(arg));
+
+ return new GroupArgumentsByOptionResult(options.ToArray(), unmatchedArgs.ToArray());
}
private string[] CreateGroupForCurrent()
@@ -79,6 +82,11 @@ private string[] CreateGroupForCurrent()
var length = optionEndIndex - (_currentOptionIndex - 1);
+ for (int i = _currentOptionIndex; i < _currentOptionIndex+length; i++)
+ {
+ _matchedArgsLookup[i] = true;
+ }
+
return _args.Skip(_currentOptionIndex)
.Take(length)
.ToArray();
@@ -137,7 +145,7 @@ static bool IsAKey(string arg)
///
static bool IsEndOfOptionsKey(string arg)
{
- return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.InvariantCultureIgnoreCase);
+ return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.OrdinalIgnoreCase);
}
}
}
\ No newline at end of file
diff --git a/FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs b/FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs
index f7dffc7..3ea283f 100644
--- a/FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs
+++ b/FluentCommandLineParser/Internals/Parsing/CommandLineParserEngineMark2.cs
@@ -49,13 +49,16 @@ public ParserEngineResult Parse(string[] args)
var grouper = new CommandLineOptionGrouper();
- foreach (var optionGroup in grouper.GroupArgumentsByOption(args))
+ var result=grouper.GroupArgumentsByOption(args);
+ foreach (var optionGroup in result.MatchedArgumentsOptionGroups)
{
string rawKey = optionGroup.First();
ParseGroupIntoOption(rawKey, optionGroup.Skip(1));
}
- return new ParserEngineResult(_parsedOptions, _additionalArgumentsFound);
+ _additionalArgumentsFound.AddRange(result.UnmatchedArgs);
+
+ return new ParserEngineResult(_parsedOptions, _additionalArgumentsFound);
}
private void ParseGroupIntoOption(string rawKey, IEnumerable optionGroup)
@@ -104,7 +107,8 @@ private static bool ShortOptionNeedsToBeSplit(ParsedOption parsedOption)
private static IEnumerable CloneAndSplit(ParsedOption parsedOption)
{
- return parsedOption.Key.Select(c => Clone(parsedOption, c)).ToList();
+ return parsedOption.Key.ToCharArray().Select(c => Clone(parsedOption, c)).ToList();
+
}
private static ParsedOption Clone(ParsedOption toClone, char c)
@@ -144,7 +148,7 @@ static bool IsAKey(string arg)
///
static bool IsEndOfOptionsKey(string arg)
{
- return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.InvariantCultureIgnoreCase);
+ return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.OrdinalIgnoreCase);
}
///
@@ -152,9 +156,9 @@ static bool IsEndOfOptionsKey(string arg)
///
/// The T:System.String[] to parse.
/// An containing the results of the parse operation.
- IEnumerable ICommandLineParserEngine.Parse(string[] args)
+ ParserEngineResult ICommandLineParserEngine.Parse(string[] args)
{
- return Parse(args).ParsedOptions;
+ return Parse(args);
}
}
}
\ No newline at end of file
diff --git a/FluentCommandLineParser/Internals/Parsing/CommandLineParserResult.cs b/FluentCommandLineParser/Internals/Parsing/CommandLineParserResult.cs
index a0c292b..fb84498 100644
--- a/FluentCommandLineParser/Internals/Parsing/CommandLineParserResult.cs
+++ b/FluentCommandLineParser/Internals/Parsing/CommandLineParserResult.cs
@@ -103,5 +103,10 @@ IEnumerable ICommandLineParserResult.UnMatchedOptions
/// Gets or sets the formatted error for this result.
///
public string ErrorText { get; set; }
- }
+
+ ///
+ /// Contains all arguments that could not be matched to any option
+ ///
+ public IEnumerable UnMatchedArgs { get; set; }
+ }
}
\ No newline at end of file
diff --git a/FluentCommandLineParser/Internals/Parsing/GroupArgumentsByOptionResult.cs b/FluentCommandLineParser/Internals/Parsing/GroupArgumentsByOptionResult.cs
new file mode 100644
index 0000000..620a982
--- /dev/null
+++ b/FluentCommandLineParser/Internals/Parsing/GroupArgumentsByOptionResult.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace FluentCommandLineParser.Internals.Parsing
+{
+ ///
+ /// result of arguments grouping
+ ///
+ public class GroupArgumentsByOptionResult
+ {
+ ///
+ /// groups of arguments matched by options
+ ///
+ public string[][] MatchedArgumentsOptionGroups { get; private set; }
+
+ ///
+ /// arguments that could not be matched to an option
+ ///
+ public string[] UnmatchedArgs { get; private set; }
+
+ ///
+ /// Initialises a new instance of the class.
+ ///
+ ///
+ ///
+ public GroupArgumentsByOptionResult(string[][] matchedArgumentsOptionGroups,string[] unmatchedArgs)
+ {
+ this.MatchedArgumentsOptionGroups=matchedArgumentsOptionGroups;
+ this.UnmatchedArgs=unmatchedArgs;
+ }
+
+ }
+}
diff --git a/FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs b/FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs
index c89a2e6..8361762 100644
--- a/FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs
+++ b/FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs
@@ -36,6 +36,6 @@ public interface ICommandLineParserEngine
///
/// The T:System.String[] to parse.
/// An representing the results of the parse operation.
- IEnumerable Parse(string[] args);
+ ParserEngineResult Parse(string[] args);
}
}
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionArgumentParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionArgumentParser.cs
index 7a63d57..70055b0 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionArgumentParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionArgumentParser.cs
@@ -41,7 +41,8 @@ public class OptionArgumentParser
/// The option.
public void ParseArguments(IEnumerable args, ParsedOption option)
{
- if (SpecialCharacters.ValueAssignments.Any(option.Key.Contains))
+
+ if (SpecialCharacters.ValueAssignments.Any(c=>option.Key.Contains(c.ToString())))
{
TryGetArgumentFromKey(option);
}
@@ -53,16 +54,15 @@ public void ParseArguments(IEnumerable args, ParsedOption option)
if (option.HasValue) allArguments.Add(option.Value);
- if (otherArguments.Any())
- {
- allArguments.AddRange(otherArguments);
+ if (otherArguments.Any())
+ {
+ allArguments.AddRange(otherArguments);
+ additionalArguments.AddRange(otherArguments);
- if (otherArguments.Count() > 1)
- {
- additionalArguments.AddRange(otherArguments);
- additionalArguments.RemoveAt(0);
- }
- }
+ if (!(option.HasValue) && additionalArguments.Count > 0)
+ additionalArguments.RemoveAt(0);
+
+ }
option.Value = allArguments.FirstOrDefault();
option.Values = allArguments.ToArray();
@@ -71,7 +71,12 @@ public void ParseArguments(IEnumerable args, ParsedOption option)
private static void TryGetArgumentFromKey(ParsedOption option)
{
- var split = option.Key.Split(SpecialCharacters.ValueAssignments, 2, StringSplitOptions.RemoveEmptyEntries);
+ var split = option.Key.Split(SpecialCharacters.ValueAssignments, StringSplitOptions.RemoveEmptyEntries);
+ //don't split in more than two parts
+ if (split.Length > 2)
+ {
+ split = new string[] { split[0], option.Key.Substring(split[0].Length+1) };
+ }
option.Key = split[0];
option.Value = split.Length > 1
@@ -91,7 +96,7 @@ static IEnumerable CollectArgumentsUntilNextKey(IEnumerable args
///
static bool IsEndOfOptionsKey(string arg)
{
- return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.InvariantCultureIgnoreCase);
+ return string.Equals(arg, SpecialCharacters.EndOfOptionsKey, StringComparison.CurrentCultureIgnoreCase);
}
}
}
\ No newline at end of file
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/BoolCommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/BoolCommandLineOptionParser.cs
index 5141f4c..a58a23a 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/BoolCommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/BoolCommandLineOptionParser.cs
@@ -40,18 +40,23 @@ public class BoolCommandLineOptionParser : ICommandLineOptionParser
/// A representing the parsed value.
/// The value is optional. If no value is provided then true is returned.
///
- public bool Parse(ParsedOption parsedOption)
+ public CommandLineOptionParserResult Parse(ParsedOption parsedOption)
{
- if (parsedOption.Value.IsNullOrWhiteSpace())
- {
- // for the suffix:
- // "-" means the value should be false
- // "+" or any other suffix means the value should be true.
- // if we don't have a
- return parsedOption.HasSuffix == false || parsedOption.Suffix != "-";
- }
-
- return bool.Parse(parsedOption.Value);
+ bool value;
+ if (parsedOption.Value.IsNullOrWhiteSpace())
+ {
+ // for the suffix:
+ // "-" means the value should be false
+ // "+" or any other suffix means the value should be true.
+ // if we don't have a
+ value= parsedOption.HasSuffix == false || parsedOption.Suffix != "-";
+ }
+ else
+ {
+ value=bool.Parse(parsedOption.Value);
+ }
+
+ return new CommandLineOptionParserResult(value, parsedOption.AdditionalValues);
}
///
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/CommandLineOptionParserResult.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/CommandLineOptionParserResult.cs
new file mode 100644
index 0000000..f57779a
--- /dev/null
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/CommandLineOptionParserResult.cs
@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Fclp.Internals.Parsing.OptionParsers
+{
+ ///
+ /// result of an option parsing
+ ///
+ public class CommandLineOptionParserResult
+ {
+ ///
+ /// direct result of the parsing
+ ///
+ public T ParsedValue { get; set; }
+
+ ///
+ /// values that were not used in the parsing
+ ///
+ public IEnumerable UnMatchedValues { get; set; }
+
+ ///
+ /// Initialises a new instance of the class.
+ /// with parsed values and unmatchedValues
+ ///
+ /// direct result of the parsing
+ /// values that were not used in the parsing
+ public CommandLineOptionParserResult(T parsedValue, IEnumerable unMatchedValues)
+ {
+ this.ParsedValue = parsedValue;
+ this.UnMatchedValues = unMatchedValues;
+ }
+
+ ///
+ /// Initialises a new instance of the class.
+ ///
+ /// direct result of the parsing
+ public CommandLineOptionParserResult(T parsedValue)
+ {
+ this.ParsedValue = parsedValue;
+ this.UnMatchedValues = Enumerable.Empty();
+ }
+
+ }
+}
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/DateTimeCommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/DateTimeCommandLineOptionParser.cs
index b076dfb..0a4628a 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/DateTimeCommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/DateTimeCommandLineOptionParser.cs
@@ -37,9 +37,10 @@ public class DateTimeCommandLineOptionParser : ICommandLineOptionParser
///
///
- public DateTime Parse(ParsedOption parsedOption)
+ public CommandLineOptionParserResult Parse(ParsedOption parsedOption)
{
- return DateTime.Parse(parsedOption.Value, CultureInfo.CurrentCulture);
+ DateTime parsedValue = DateTime.Parse(parsedOption.Value, CultureInfo.CurrentCulture);
+ return new CommandLineOptionParserResult(parsedValue, parsedOption.AdditionalValues);
}
///
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/DoubleCommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/DoubleCommandLineOptionParser.cs
index 215ad79..f49e940 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/DoubleCommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/DoubleCommandLineOptionParser.cs
@@ -31,15 +31,16 @@ namespace Fclp.Internals.Parsing.OptionParsers
///
public class DoubleCommandLineOptionParser : ICommandLineOptionParser
{
- ///
- /// Parses the specified into a .
- ///
- ///
- ///
- public double Parse(ParsedOption parsedOption)
- {
- return double.Parse(parsedOption.Value, CultureInfo.InvariantCulture);
- }
+ ///
+ /// Parses the specified into a .
+ ///
+ ///
+ ///
+ public CommandLineOptionParserResult Parse(ParsedOption parsedOption)
+ {
+ double parsedValue = double.Parse(parsedOption.Value, CultureInfo.InvariantCulture);
+ return new CommandLineOptionParserResult(parsedValue, parsedOption.AdditionalValues);
+ }
///
/// Determines whether the specified can be parsed by this .
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/ICommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/ICommandLineOptionParser.cs
index eda4c67..b9e3fa4 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/ICommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/ICommandLineOptionParser.cs
@@ -32,8 +32,8 @@ public interface ICommandLineOptionParser
/// Parses the specified into the return type.
///
///
- /// The parsed value.
- T Parse(ParsedOption parsedOption);
+ /// The parse result.
+ CommandLineOptionParserResult Parse(ParsedOption parsedOption);
///
/// Determines whether the specified can be parsed by this .
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/Int32CommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/Int32CommandLineOptionParser.cs
index 87289c2..efb53a6 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/Int32CommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/Int32CommandLineOptionParser.cs
@@ -23,6 +23,7 @@
#endregion
using System.Globalization;
+using System.Linq;
namespace Fclp.Internals.Parsing.OptionParsers
{
@@ -36,9 +37,10 @@ public class Int32CommandLineOptionParser : ICommandLineOptionParser
///
///
///
- public int Parse(ParsedOption parsedOption)
+ public CommandLineOptionParserResult Parse(ParsedOption parsedOption)
{
- return int.Parse(parsedOption.Value, CultureInfo.CurrentCulture);
+ int parsedValue = int.Parse(parsedOption.Value, CultureInfo.InvariantCulture);
+ return new CommandLineOptionParserResult(parsedValue, parsedOption.AdditionalValues);
}
///
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/ListCommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/ListCommandLineOptionParser.cs
index c01c73b..a0eccbd 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/ListCommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/ListCommandLineOptionParser.cs
@@ -49,16 +49,19 @@ public ListCommandLineOptionParser(ICommandLineOptionParserFactory parserFactory
///
///
/// The parsed value.
- public List Parse(ParsedOption parsedOption)
+ public CommandLineOptionParserResult> Parse(ParsedOption parsedOption)
{
var parser = _parserFactory.CreateParser();
-
- return parsedOption.Values.Select(value =>
+
+ List parsedValues= parsedOption.Values.Select(value =>
{
var clone = parsedOption.Clone();
clone.Value = value;
- return parser.Parse(clone);
+ return parser.Parse(clone).ParsedValue;
}).ToList();
+
+ return new CommandLineOptionParserResult>(parsedValues);
+
}
///
diff --git a/FluentCommandLineParser/Internals/Parsing/OptionParsers/StringCommandLineOptionParser.cs b/FluentCommandLineParser/Internals/Parsing/OptionParsers/StringCommandLineOptionParser.cs
index 4aafd31..7a7f73d 100644
--- a/FluentCommandLineParser/Internals/Parsing/OptionParsers/StringCommandLineOptionParser.cs
+++ b/FluentCommandLineParser/Internals/Parsing/OptionParsers/StringCommandLineOptionParser.cs
@@ -37,9 +37,10 @@ public class StringCommandLineOptionParser : ICommandLineOptionParser
///
///
///
- public string Parse(ParsedOption parsedOption)
+ public CommandLineOptionParserResult Parse(ParsedOption parsedOption)
{
- return parsedOption.Value.RemoveAnyWrappingDoubleQuotes();
+ string parsedValue = parsedOption.Value.RemoveAnyWrappingDoubleQuotes();
+ return new CommandLineOptionParserResult(parsedValue, parsedOption.AdditionalValues);
}
///
diff --git a/FluentCommandLineParser/Internals/Validators/OptionNameValidator.cs b/FluentCommandLineParser/Internals/Validators/OptionNameValidator.cs
index 3cd85ad..52059f2 100644
--- a/FluentCommandLineParser/Internals/Validators/OptionNameValidator.cs
+++ b/FluentCommandLineParser/Internals/Validators/OptionNameValidator.cs
@@ -93,7 +93,7 @@ private static void VerifyDoesNotContainsReservedChar(string value)
foreach (char reservedChar in ReservedChars)
{
- if (value.Contains(reservedChar))
+ if (value.Contains(reservedChar.ToString()))
{
ThrowInvalid(value, "The character '" + reservedChar + "' is not valid within a short or long name.");
}
diff --git a/FluentCommandLineParser/InvalidOptionNameException.cs b/FluentCommandLineParser/InvalidOptionNameException.cs
index f59cd0d..eca805e 100644
--- a/FluentCommandLineParser/InvalidOptionNameException.cs
+++ b/FluentCommandLineParser/InvalidOptionNameException.cs
@@ -33,36 +33,11 @@ namespace Fclp
public class InvalidOptionNameException : Exception
{
///
- /// Initializes a new instance of the class.
- ///
- public InvalidOptionNameException()
- {
- }
-
- ///
- /// Initializes a new instance of the class.
+ /// Initialises a new instance of the class.
///
/// The message that describes the error.
public InvalidOptionNameException(string message) : base(message)
{
}
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The error message that explains the reason for the exception.
- /// The exception that is the cause of the current exception, or a null reference (Nothing in Visual Basic) if no inner exception is specified.
- public InvalidOptionNameException(string message, Exception innerException) : base(message, innerException)
- {
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The that holds the serialized object data about the exception being thrown.
- /// The that contains contextual information about the source or destination.
- protected InvalidOptionNameException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
}
}
\ No newline at end of file
diff --git a/FluentCommandLineParser/OptionAlreadyExistsException.cs b/FluentCommandLineParser/OptionAlreadyExistsException.cs
index 4111adc..d873646 100644
--- a/FluentCommandLineParser/OptionAlreadyExistsException.cs
+++ b/FluentCommandLineParser/OptionAlreadyExistsException.cs
@@ -30,35 +30,12 @@ namespace Fclp
///
/// Represents an error that has occurred because a matching Option already exists in the parser.
///
- [Serializable]
public class OptionAlreadyExistsException : Exception
{
- ///
- /// Initialises a new instance of the class.
- ///
- public OptionAlreadyExistsException() { }
-
///
/// Initialises a new instance of the class.
///
///
public OptionAlreadyExistsException(string optionName) : base(optionName) { }
-
- ///
- /// Initialises a new instance of the class.
- ///
- ///
- ///
- public OptionAlreadyExistsException(SerializationInfo info, StreamingContext context)
- : base(info, context) { }
-
- ///
- /// Initialises a new instance of the class.
- ///
- ///
- ///
- public OptionAlreadyExistsException(string optionName, Exception innerException)
- : base(optionName, innerException) { }
-
}
}
diff --git a/FluentCommandLineParser/OptionSyntaxException.cs b/FluentCommandLineParser/OptionSyntaxException.cs
index 10521b0..5097ae9 100644
--- a/FluentCommandLineParser/OptionSyntaxException.cs
+++ b/FluentCommandLineParser/OptionSyntaxException.cs
@@ -23,13 +23,13 @@
#endregion
using System;
+using System.Runtime.Serialization;
namespace Fclp
{
///
/// Represents an error that has occurred because a Option syntax was in an unexpected format.
///
- [Serializable]
public class OptionSyntaxException : Exception
{
}
diff --git a/FluentCommandLineParser/Properties/AssemblyInfo.cs b/FluentCommandLineParser/Properties/AssemblyInfo.cs
index dd679cd..4b9800a 100644
--- a/FluentCommandLineParser/Properties/AssemblyInfo.cs
+++ b/FluentCommandLineParser/Properties/AssemblyInfo.cs
@@ -25,7 +25,6 @@
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
@@ -39,16 +38,7 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("b563a988-ae88-4bcc-b6ab-e167f941a167")]
-
-// Allows us to unit test the 'internals'
-//[assembly: InternalsVisibleTo("FluentCommandLineParser.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100ad2e88658ff62cac7d7ececd3ac22c6d39ee4e19a09d61acae936f9497df38fa3db020d2b607c8176cd754c7e3a8cdc10559bedcbaaeed76e277f0d009b39bab687261567a1f2da2c3d63b913822ee944664e29bcb85d6b49b87c7d6ee44647ec5252379ed5e4c09d787f6753cf2fdf4a1c1890eedc655738d466bb6f3b91396")]
[assembly: InternalsVisibleTo("FluentCommandLineParser.Tests")]
// !! DO NOT CHANGE - VERSIONS ARE HANDLED AUTOMATICALLY FROM THE CONTINUOUS INTEGRATION SERVER!!
[assembly: AssemblyVersion("1.0.0.0")]
diff --git a/FluentCommandLineParser/UnsupportedTypeException.cs b/FluentCommandLineParser/UnsupportedTypeException.cs
index 12559ac..3e70606 100644
--- a/FluentCommandLineParser/UnsupportedTypeException.cs
+++ b/FluentCommandLineParser/UnsupportedTypeException.cs
@@ -23,13 +23,13 @@
#endregion
using System;
+using System.Runtime.Serialization;
namespace Fclp
{
///
/// Represents an error that has occurred because a specified type is unsupported.
///
- [Serializable]
public class UnsupportedTypeException : Exception
{
}
diff --git a/TestResults/FluentCommandLineParser.TE.Tests.mdf b/TestResults/FluentCommandLineParser.TE.Tests.mdf
new file mode 100644
index 0000000..2987f0b
Binary files /dev/null and b/TestResults/FluentCommandLineParser.TE.Tests.mdf differ
diff --git a/TestResults/FluentCommandLineParser.TE.Tests_log.ldf b/TestResults/FluentCommandLineParser.TE.Tests_log.ldf
new file mode 100644
index 0000000..943d835
Binary files /dev/null and b/TestResults/FluentCommandLineParser.TE.Tests_log.ldf differ