Skip to content
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

Does not recognize files that start with a slash, e.g. "/var/log/test.txt" #42

Open
dpagano opened this issue Jun 30, 2015 · 4 comments

Comments

@dpagano
Copy link

dpagano commented Jun 30, 2015

When setting up for retrieving file names (p.Setup<List>('f', "files")), the resulting parser does not recognize file names that start with a slash, such as "/var/log/test.txt" or "/Users/fclp/test.txt".
I suppose this is because the slash is interpreted as an option.
However, I did not find anything that lets me disable "/" as option trigger.
Note that such file names are standard on Linux / Mac environments.

@siywilliams
Copy link
Member

Thanks @dpagano

I will have a look and see what can be done about intelligently detecting file paths. Another good thing to add to the library is what you mentioned - optionally disable the "/" prefix altogether.

In the meantime you can use -- to tell the parser that no more options are to follow which will then parse "/Users/fclp/test.txt" correctly.

For example:

myapp.exe --debug --file -- "/Users/fclp/test.txt"
myapp.exe --debug --file -- "/Users/fclp/test.txt" "/Users/fclp/test2.txt "/Users/fclp/tes3.txt"

I hope that works for you in the meantime.

@dpagano
Copy link
Author

dpagano commented Jul 6, 2015

Thanks for your answer @siywilliams
Yes, I know about the -- switch. It helps as long as you don't have two options both of which asking for files :) (such as -input -output e.g.)

@petero-dk
Copy link

petero-dk commented Sep 30, 2016

I have this exact problem which really is an issue when running programs on mono (mac or linux)

Right now what I do is run through all arguments before giving them to fluent command line parser and adding: :: if it starts with /, once i get the result back i check for ::/ and remove the ::

Quite a hack!

            for (var i = 0; i < args.Length; i++) 
                if (args[i][0] == '/')
                    args[i] = "::" + args[i];

@siywilliams
Copy link
Member

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

siywilliams added a commit that referenced this issue Nov 26, 2017
… use "/" for example), plus disable the short option behaviour entirely.

#39 #42 #58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants