Example #1
0
        public bool checkIfKeyValueIsValid(bool autofillquery, string key, string value)
        {
            for (int i = 0; i < options.Count; i++)
            {
                Option op = options.ElementAt(i);
                if (op.marked == false || autofillquery)
                {
                    if (op.checkIfKeyValueIsValid(key.Trim(), value))
                    {
                        if (!autofillquery)
                        {
                            op.marked = true;
                        }
                        return(true);
                    }
                }
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup op = optionsG.ElementAt(i);
                if (op.marked == false || autofillquery)
                {
                    if (op.checkIfKeyValueIsValid(key.Trim(), value))
                    {
                        if (!autofillquery)
                        {
                            op.marked = true;
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
        public string[] get_all_user_options()
        {
            string[] prepare = new string[100];
            int      counter = 0;

            for (int i = 0; i < options.Count; i++)
            {
                Option op = options.ElementAt(i);
                if (op.marked == false)
                {
                    prepare[counter++] = op.key;
                }
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup op = optionsG.ElementAt(i);
                if (op.marked == false)
                {
                    prepare[counter++] = op.get_key_rep();
                }
            }

            string[] retval = new string[counter];
            for (int i = 0; i < counter; i++)
            {
                retval[i] = "\t" + prepare[i];
            }
            return(retval);
        }
Example #3
0
        public void clearMarked()
        {
            for (int i = 0; i < options.Count; i++)
            {
                Option op = options.ElementAt(i);
                op.marked = false;
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup op = optionsG.ElementAt(i);
                op.marked = false;
            }
        }
Example #4
0
        /*
         * 'marked' options will be included, rest need not be.!!
         */
        public string[] get_possible_values(string key)
        {
            for (int i = 0; i < options.Count; i++)
            {
                Option op = options.ElementAt(i);
                if (op.marked == true && op.key == key)
                {
                    return(op.get_valuelist(key));
                }
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup op = optionsG.ElementAt(i);
                if (op.marked == true && op.checkIfKeyValueIsValid(key, null))
                {
                    return(op.get_valuelist(key));
                }
            }
            return(null);
        }
Example #5
0
        public void print_contents()
        {
            string mids = "";

            for (int i = 0; i < maincmd_ids.Length; i++)
            {
                mids += maincmd_ids[i] + ((i == (maincmd_ids.Length - 1)) ? "" : ",");
            }
            Console.WriteLine("subcmd   " + subcmd_name + " " + mids);

            for (int i = 0; i < options.Count; i++)
            {
                Option o = options.ElementAt(i);
                o.print_contents();
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup og = optionsG.ElementAt(i);
                og.print_contents();
            }
        }
Example #6
0
        private void do_multiple_op_parsing(bool c, string str)
        {
            string newstr = (c) ? str.Substring(1) : str;

            char[]   sep    = { ' ', '\t' };
            string[] tokens = newstr.Split(sep, StringSplitOptions.RemoveEmptyEntries);

            for (int i = 0; i < tokens.Length; i++)
            {
                tokens[i] = tokens[i].Trim();
            }

            string[] cmdopkey_all    = tokens[0].Split('/');
            string[] cmdopvalues_all = tokens[1].Split('/');

            OptionGroup cmdgroup = new OptionGroup(c);

            for (int i = 0; i < cmdopkey_all.Length; i++)
            {
                string   cmdopkey    = cmdopkey_all[i];
                string[] cmdopvalues = cmdopvalues_all[i].Split(',');

                Option newcmdop;
                if (cmdopvalues.Length == 1)
                {
                    int type = (tokens[1].IndexOf("INT") != -1) ? 0 : 1;
                    newcmdop = new Option(c, cmdopkey, type);
                }
                else
                {
                    newcmdop = new Option(c, cmdopkey, cmdopvalues);
                }
                cmdgroup.insert_cmdoption(newcmdop);
            }
            optionsG.Add(cmdgroup);
        }
Example #7
0
        public string autofill_key(string partial)
        {
            for (int i = 0; i < options.Count; i++)
            {
                Option op = options.ElementAt(i);
                if (op.marked == false && op.key.IndexOf(partial) == 0)
                {
                    op.marked = true;
                    return(op.key);
                }
            }

            for (int i = 0; i < optionsG.Count; i++)
            {
                OptionGroup op = optionsG.ElementAt(i);
                string      str1;
                if (op.marked == false && (str1 = op.autofill_key(partial)) != null)
                {
                    op.marked = true;
                    return(str1);
                }
            }
            return(null);
        }