Example #1
0
        public static Dictionary <string, string> Parse(string[] args)
        {
            Dictionary <string, string> returnVal = new Dictionary <string, string>();

            // set defaults
            returnVal["f"] = null;
            returnVal["s"] = null;
            returnVal["h"] = null;
            string currentKey = "";

            foreach (string str in args)
            {
                if (str.Substring(0, 1) == "-")
                {
                    currentKey = str.Substring(1);
                    bool expectedKey = false;
                    foreach (string exp in returnVal.Keys)
                    {
                        if (string.Equals(currentKey, exp, StringComparison.OrdinalIgnoreCase))
                        {
                            expectedKey = true;
                            break;
                        }
                    }
                    if (!expectedKey)
                    {
                        ArgParser.Usage();
                    }
                    else
                    {
                        returnVal[currentKey] = "";
                    }
                }
                else
                {
                    returnVal[currentKey] = str;
                }
            }
            if (returnVal["h"] != null)
            {
                ArgParser.Usage();
            }
            return(returnVal);
        }