Before we get to the meat of this blog post, I want to take a moment to introduce myself. My name is Matt Ellis and I’m working this summer as an intern on the Base Class Libraries team. I’m really enjoying my time here, and it’s pretty amazing to be working on a team whose work affects so many developers around the world!
One feature we are considering adding to a future release on the .NET Framework is a library to help developers writing applications that use command line arguments. We’d like to be able to provide a simple framework for parsing these arguments so our users don’t have to waste time writing boilerplate code that extracts and validates arguments from the string array passed into the main method, and can instead focus on solving the problem at hand.
The Windows PowerShell team has developed some framework to solve this problem in their space. One of the key concepts in PowerShell is the Cmdlet, which is a small .NET class run within PowerShell to perform a specific task. Authors of Cmdlets simply declare, via attributes within their code, properties and fields that should be used as command line arguments. PowerShell takes care of filling in these fields and properties based on arguments that come in from the command line. PowerShell makes sure the types of incoming arguments are valid, that all mandatory arguments are given values and can even print usage information for an application. You can read more about PowerShell by downloading the Microsoft Windows SDK for Beta 2. This is all really cool technology, but it requires PowerShell. We’d like to be able to deliver a solution that would only require the .NET Framework.
So we want to ask you, our customers, what features you’d like to see in a command line argument parser. For example, is the ability to have order dependent parameters important, or should copy -A -V source.txt dest.txt work the same as copy -V -A source.txt dest.txt or copy source.txt dest.txt -A –V? What about the ability to specify dependencies between arguments, such as –A can only appear if –B is also somewhere on the command line? What features are most important to you when it comes to writing programs that take command line arguments?