Пример #1
0
            public override void Execute( )
            {
                cmdalias_t a = null;

                if (Cmd.Argc() == 1)
                {
                    Com.Printf("Current alias commands:\\n");
                    for (a = Globals.cmd_alias; a != null; a = a.next)
                    {
                        Com.Printf(a.name + " : " + a.value);
                    }

                    return;
                }

                var s = Cmd.Argv(1);

                if (s.Length > Defines.MAX_ALIAS_NAME)
                {
                    Com.Printf("Alias name is too long\\n");
                    return;
                }

                for (a = Globals.cmd_alias; a != null; a = a.next)
                {
                    if (s.EqualsIgnoreCase(a.name))
                    {
                        a.value = null;
                        break;
                    }
                }

                if (a == null)
                {
                    a                 = new cmdalias_t();
                    a.next            = Globals.cmd_alias;
                    Globals.cmd_alias = a;
                }

                a.name = s;
                var cmd = "";
                var c   = Cmd.Argc();

                for (var i = 2; i < c; i++)
                {
                    cmd = cmd + Cmd.Argv(i);
                    if (i != (c - 1))
                    {
                        cmd = cmd + " ";
                    }
                }

                cmd     = cmd + "\\n";
                a.value = cmd;
            }
Пример #2
0
        public static ArrayList CompleteCommand(String partial)
        {
            ArrayList cmds = new ArrayList();

            for (cmd_function_t cmd = cmd_functions; cmd != null; cmd = cmd.next)
            {
                if (cmd.name.StartsWith(partial))
                {
                    cmds.Add(cmd.name);
                }
            }
            for (cmdalias_t a = Globals.cmd_alias; a != null; a = a.next)
            {
                if (a.name.StartsWith(partial))
                {
                    cmds.Add(a.name);
                }
            }
            return(cmds);
        }