Some suggestions for the a .NET 2.0 version:
public static T GetOptions<T>() where T : new()
{
return GetOptions<T>(System.Environment.CommandLine);
}
public static T GetOptions<T>(string commandLine) where T : new()
{
return GetOptions<T>(commandLine, true);
}
public static T GetOptions<T>(string commandLine, bool includesProgramName) where T : new()
{
T result = new T();
CommandLineParser parser = new CommandLineParser(result);
parser.Parse(commandLine, includesProgramName);
return result;
}
public static string GetCommandLine()
{
return System.Environment.CommandLine;
}
public static string GetUsage<T>() where T : new()
{
T result = new T();
CommandLineParser parser = new CommandLineParser(result);
parser.Parse(System.Environment.CommandLine, true);
return parser.Usage;
}
public static string GetExplicitOptions<T>() where T : new()
{
T result = new T();
CommandLineParser parser = new CommandLineParser(result);
parser.Parse(System.Environment.CommandLine, true);
return parser.ExplicitOptions;
}