ProcessCommandLineArguments ( IList args, string>.ICollection options, string atFolder, string>.IDictionary shortOptions = null, InvertibleSet twoArgOptions = null, int argLimit = 0xFFFF, bool expandEnvVars = true, bool caseSensitiveLongOpts = false ) : void |
Expands environment variables (e.g. %TEMP%) and @files in a list of command-line arguments, and adds any options of the form "--opt" or "--opt=value" to a dictionary. Two types of options are recognized, short (-s) and long (--long), and only one argument is supported per option. The documentation is above. You can choose whether to permit duplicate options or not. If you use a standard Dictionary{K,V} to hold the options, an exception will occur when this method calls Add() to add the duplicate. The exception is caught, the first ocurrance is kept, and a warning message is printed to MessageSink.Default. To allow duplicates, store options in a different data structure such as List(KeyValuePair(string, string)) or BMultiMap(string,string) . DOS-style slash-options like /foo are not supported. Since Windows recognizes the forward slash as a path separator, forward-slash options can be recognized as paths. If you want to recognize them as options instead, you can preprocess the argument list, replacing every command that starts with "/" with a "--" command: for (int i = 0; args.Count > i; i++) if (args[i].StartsWith("/")) args[i] = "--" + args[i].Substring(1); Globs (e.g. *.txt) are not recognized or expanded, but environment variables are expanded when expandEnvVars is true. Quote marks are not processed. An argument of "--a" , with quote marks, is not recognized as an option (these quote marks should be removed before calling this method, e.g. G.SplitCommandLineArguments handles this.) |
|