-
Notifications
You must be signed in to change notification settings - Fork 293
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
Seem to have to use "--" to pass an argument? (Forward "/" syntax not supported) #108
Comments
AFAIK the double-dash is your only option. For a bit of context, Windows is the only OS that uses See getopt short and long options for the syntax this library is based on. |
Thanks Dan -- do get what you are saying, but most of my users are windows Thanks all! On Thursday, November 7, 2013, Dan Nemec wrote:
|
There is a setting you can disable two dashes. The documentation for input parameters is here: https://commandline.codeplex.com/wikipage?title=Attributes-Define-Your-Syntax I suggest mainly you cope with /? or something like that - so people will be able to read documentation. |
Can the support for /{single letter}, /{long word} and/or /? for help be added? |
You could easily allow modifying the
|
I'd be happy with that. Mostly I just want /? to be --help and /c short commands. Could it work both ways simultaneously? example.exe /m -v --file File.txt |
This and this might be where you can change the help command. Here is where the dashes are processed. The easiest thing to do would be to replace dashes with slashes, but you might be able to modify the tokenizer to accept slashes for short commands and dashes for long ones. Of course, the whole idea is moot if you're not interested in compiling it yourself. I haven't seen the author around here in over a year. |
In 2.0 is even simpler hack the code. Or better, hack Parser.cs and supply it your tokenize function. If you want stop processing for special OK? I close the issue for now. Thanks everyone for nice discussion! 👍 |
@gsscoder, my goal in this is not to 'hack the code' in a one-off sense, I'm asking if '/' can be added to the Tokenizer for the main trunk, by default. If you would accept the pull request I will create one and test it, but I'm essentially asking why '/a', '/b', '/?' can't be by default interpreted as '-a', '-b', '--help'? This is coming from a windows-centric mindset, where arguments are frequently prefaced with /. |
@Ehryk I don't think that this request will ever make it in as the "Windows" style wouldn't work with some features integral to the "getopt" style -- namely, short name merging ( While it's possible from a technical perspective, this project strives to adhere to the getopt style of parameter passing and a Windows-centric style parser might be better off as a separate project. Windows-style parsing has its own methods of escaping and delimiting that I would expect to be included in a good library but are incompatible with getopt. |
Why couldn't it support proper getopt, with forward slashes too? For example, |
That would work, but I assume you want to support long names with a single slash, too, rather than a double slash.
This would have an ambiguous definition when using |
@Ehryk, |
@gsscoder no, @nemec I'm completely happy with a hybrid approach: The only issue I see here is non-Windows pathing: |
@Ehryk in that case I have a many fewer objections. The double slash looks weird to me but as long as the documentation is clear that it only affects the argument delimiter and otherwise parsing is the same, I don't see why it couldn't be added. For Under non-Windows, you (as in the app, not CommandLine) could add your own OS detection and choose the flag delimiter based on that. Unfortunately, you can't quote the path before executing because cmd/ps will do some lexing for you.
|
agree with @nemec about now, @Ehryk, the point is to define a new standard or in library internals a new @nemec, will be agree with me that a possible solution could be add boolean property in on a thing I'm sure: I'm against to allow hybrid between *nix and Windows syntax! |
I'm using version 1.9.71 (latest from nuget as of today). I'm a fairly new user, so maybe I'm doing something wrong, but I found that it only parses successfully if each arguement is passed with a double dash, like:
myApp --arg1 value --arg2 value etc.
I can do that, but it seems kind of unusual. Most users are used to either a single dash or a forward slash to specify args. Is there a way to change that behavior?
if it helps, here is a snippet of my option class:
class CommandLineOptions
{
[Option("longname", Required=true, HelpText="blah")]
public string TheProperty { get; set; }
The text was updated successfully, but these errors were encountered: