-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escaped quote at the end of quoted argument #106
Comments
The problem is in the public static string RemoveAnyWrappingDoubleQuotes(this string str)
{
return str.IsNullOrWhiteSpace()
? str
: str.TrimStart('"').TrimEnd('"');
}
Here is test case [TestFixture]
public class when_there_is_qoute_in_the_end
{
[Test]
public void parser()
{
var args = new[] { "--param", "something \"4\"" };
var sut = new Fclp.FluentCommandLineParser<Config>();
sut.Setup(_ => _.Param).As('p', "param");
var res = sut.Parse(args);
Assert.AreEqual("something \"4\"", sut.Object.Param);
}
[Test]
public void RemoveAnyWrappingDoubleQuotes()
{
var str = "something \"4\"";
str = str.WrapInDoubleQuotes();
str = str.RemoveAnyWrappingDoubleQuotes();
Assert.AreEqual("something \"4\"", str);
}
} I've adjusted the public static string RemoveAnyWrappingDoubleQuotes(this string str)
{
if (!str.IsNullOrWhiteSpace())
if (str.StartsWith("\"") && str.EndsWith("\""))
return str.Substring(1, str.Length - 2);
return str;
} and it works |
I ran into a little bug with the latest Nuget package (1.4.3).
--param "something something"
is parsed assomething something
--param "something \"{4}\" something"
is parsed assomething \"4\" something
However:
--param "something \"{4}\""
is expected to besomething \"4\"
but instead gives mesomething \"4
, dropping the final quote.Thanks for a nice library!
The text was updated successfully, but these errors were encountered: