Exemplo n.º 1
0
        public bool Parse(string[] args)
        {
            /*
             * Defaults
             */
            this.Mode = ValidationMode.Live;


            /*
             * Parse
             */
            var p = new OptionSet()
            {
                { "m=", v => this.Mode = Enumerate.ParseInsensitive <ValidationMode>(v) },
                { "o=", v => this.OutputDirectory = v },
                { "output-directory=", v => this.OutputDirectory = v },

                { "h|help", v => this.Help = true },
                { "t|validate", v => this.ValidateOnly = true },
                { "v|verbose", v => this.Verbose = true },
            };

            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                return(false);
            }


            /*
             * Stop parsing the remainder of the options, if the user has
             * specified that he wishes to view the help.
             */
            if (this.Help == true)
            {
                return(true);
            }


            /*
             * All extra parameters are file patterns, which need to be
             * expanded.
             */
            this.FilePatterns = extra;

            return(true);
        }