fclp / fluent-command-line-parser

A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface
Other
530 stars 85 forks source link

How do you escape a parameter that starts with the '/' character? #87

Open tzejohn opened 7 years ago

tzejohn commented 7 years ago

I have an option where I am passing in path parameters, and these are prefixed by '/'. The parser is interpreting these as additional long options instead of as parameter values for the previous flag. I have tried wrapping the value in double quotes, which does not work. I also tried single quotes. But in that case, the single quotes also get passed through. Is there any way to disable or escape leading '/' values in parameters?

siywilliams commented 6 years ago

You need to use something called bare double dash which is to use the characters -- to signify to the parser that there are no more options after than point.

For example: myapp.exe --path -- \path\to\directory myapp.exe --p -- \path\to\directory

siywilliams commented 6 years ago

In v2.0 you will be able to do var fclp = new FluentCommandLineParser().UseOwnOptionPrefix("-", "--"); which will omit the "/" prefix altogether solving this issue.

sinistram commented 5 years ago

Hi guys, when do you planing to release version 2.0?

siywilliams commented 5 years ago

@sinistram no strong plan as of yet however if it is UseOwnOptionPrefix functionality you're after I beleive it is in the commands pre-release https://www.nuget.org/packages/FluentCommandLineParser/1.5.0.20-commands

sinistram commented 5 years ago

@siywilliams, nice) Thank you

DenisBalan commented 4 years ago

if you have already an app with this library and cannot modify path, just append parent dots. dotnet myapp.dll -f /file.txt error is Option '-f' parse error: could not parse '' to 'System.String'. what really should be is something like dotnet myapp.dll -f ../../../../../../file.txt (first char not to be /) and that works!