Esempio n. 1
0
        protected override bool DoResolve(ScriptingContext context)
        {
            if ((Args == null) || (Args.Count < 1)) {
                context.Print ("Need an argument:{0}", GetCommandList());
                return false;
            }

            Type subcommand_type = (Type)subcommand_type_hash[(string) Args[0]];

            if (subcommand_type == null)
                throw new ScriptingException ("Syntax error");

            subcommand = (DebuggerCommand) Activator.CreateInstance (subcommand_type);

            ArrayList new_args = new ArrayList ();
            for (int i = 1; i < Args.Count; i++)
                new_args.Add (Args [i]);

            DebuggerEngine engine = context.Interpreter.DebuggerEngine;
            subcommand = (DebuggerCommand) engine.ParseArguments (subcommand, new_args);
            if (subcommand == null)
                return false;

            return subcommand.Resolve (context);
        }
Esempio n. 2
0
        public override string[] Complete(Engine e, string text)
        {
            // this doesn't quite work yet.  in the end it
            // should allow completion of subcommand arguments,
            // but for now it just offers completion of the
            // subcommand.

            if (Args != null && Args.Count > 0) {
                /* the user tabbed after the space in the
                 * arguments.  the first arg is meant to
                 * identify the subcommand, and the next
                 * args are the subcommand arguments.  so
                 * push this off to the subcommand's
                 * completer. */
                Type subcommand_type = (Type)subcommand_type_hash[(string) Args[0]];
                if (subcommand_type == null) {
                    return e.Completer.NoopCompleter (text);
                }
                else {
                    /* copied from above */
                    subcommand = (DebuggerCommand) Activator.CreateInstance (subcommand_type);
                    ArrayList new_args = new ArrayList ();
                    for (int i = 1; i < Args.Count; i++)
                        new_args.Add (Args [i]);
                    subcommand.Args = new_args;

                    return subcommand.Complete (e, text);
                }
            }

            if (subcommand_type_hash.Count == 0) {
                return e.Completer.NoopCompleter (text);
            }
            else {
                string[] haystack = new string[subcommand_type_hash.Count];
                subcommand_type_hash.Keys.CopyTo (haystack, 0);
                return e.Completer.StringsCompleter (haystack, text);
            }
        }