I'm looking for a command line argument parser, such as "Command line parser" from http://www.sellsbrothers.com/tools/Genghis/ .
Features I'm looking for:
P.S : "Command line parser" is quite good, I really like the design of it but there is no documentation, no new updates and I couldn't figure out to do certain stuff such as how to check for required parameters.
The arguments which are passed by the user or programmer to the Main() method is termed as Command-Line Arguments. Main() method is the entry point of execution of a program. Main() method accepts array of strings. But it never accepts parameters from any other method in the program.
The string[] args is a variable that has all the values passed from the command line as shown above. Now to print those arguments, let's say we have an argument, “One” − Console. WriteLine("Length of the arguments: "+args. Length); Console. WriteLine("Arguments:"); foreach (Object obj in args) { Console.
argparse — parse the arguments. Using argparse is how you let the user of your program provide values for variables at runtime. It's a means of communication between the writer of a program and the user.
My personal favourite 3rd party commandline parsing library is Command Line Parser and I assume this is the one you are referring to. The most recent release was less than 2 months ago and there are regular commits. If you want a more mature offering you could check out the console library in the mono project (sorry I can't seem to find a direct link to the namespace at the moment, but its a part of the mono framework)
Have a look at ndesk.options.
It is called Mono.Options now.
A popular and pretty comprehensive C command-line parser is GNU getopt. This has been ported (or cloned) for C#/.Net several times. Some of these include:
Take your pick! There are several others, and google can tell you about those,
Sadly there's no built in support for handling that in a standard manner. Have you looked into PowerShell? I bet there's a class in that shell which does exactly what you want or something similar.
Edit: as fatcat1111 points out, this feature did not ship with the final version of .net 4.0.
C# 4.0 has a pretty good one. Probably not very helpful yet, but you might want to consider looking at something that will make the jump to the built in one easy when it comes out. Bart De Smet talked about it on his B# blog
I suggest NDesk.Options
look here:
Best way to parse command line arguments in C#?
Consider that once you start using this parser, you'll either have to maintain it yourself, or else depend on someone else to maintain it for you. You may be better off writing your own, starting from your most critical, immediate, requirements. I've found that it doesn't take too much work to produce some fairly complicated command-line parsing for most console-based applications I've worked on.
I've also found that when the parsing gets too complicated, it may be time to stop using the command line.
I'm betting this is not quite what you're looking for, but:
Somebody here had that problem, and his first thought was "hey, ocaml has a pretty good one!", and quickly ported it to F#.
I'm using the parser out of the C# 3.0 cookbook.
All the examples from this book can be downloaded here: http://examples.oreilly.com/9780596516109/
Search for 'Arguments' and you'll find it. You have to do some little code changes to get it out of the whole thing into your own class, but this is no big problem.
It supports all your points except the last two ones (parameter combining & missing space).
The BizArk library contains a command-line parser.
Basically you just create a class that inherits from CmdLineObject, add properties that you want populated from the command-line, add a CmdLineArgAttribute to the properties, then call Initialize in your program. It supports ClickOnce URL arguments too!
Features (from the site)...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With