Ejemplo n.º 1
0
 /// <summary>
 /// Parses Command Line Arguments. 
 /// Use ArgumentAttributes to control parsing behaviour.
 /// </summary>
 /// <param name="arguments"> The actual arguments. </param>
 /// <param name="destination"> The resulting parsed arguments. </param>
 /// <param name="reporter"> The destination for parse errors. </param>
 /// <returns> true if no errors were detected. </returns>
 public static bool ParseArguments(string[] arguments, object destination, ErrorReporter reporter)
 {
     Parser parser = new Parser(destination.GetType(), reporter);
     return parser.Parse(arguments, destination);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Checks if a set of arguments asks for help.
 /// </summary>
 /// <param name="args"> Args to check for help. </param>
 /// <returns> Returns true if args contains /? or /help. </returns>
 public static bool ParseHelp(string[] args)
 {
     Parser helpParser = new Parser(typeof(HelpArgument), new ErrorReporter(NullErrorReporter));
     HelpArgument helpArgument = new HelpArgument();
     helpParser.Parse(args, helpArgument);
     return helpArgument.help;
 }
Ejemplo n.º 3
0
Archivo: UI.cs Proyecto: newbish/hfmcmd
 /// <summary>
 /// Parses the supplied set of arg strings using the list of Argument
 // definitions maintained by this command-line UI instance.
 /// </summary>
 public Dictionary<string, object> Parse(IEnumerable<string> args)
 {
     var parser = new Parser(Definition);
     var result = parser.Parse(new List<string>(args));
     if(parser.ShowUsage) {
         DisplayUsage(System.Console.Error, result);
         result = null;  // Don't act on whatever we parsed
     }
     else if(parser.ParseException != null) {
         throw parser.ParseException;
     }
     return result;
 }