コード例 #1
0
        void OnCommands(string text, Color color)
        {
            if (text[0] == kCommandPrefix)
            {
                Command.Base command;

                string[] args = text.Trim().Remove(0, 1).Split(' ');

                if (commands.TryGetValue(args[0], out command) != false)
                {
                    var context = new Command.Context(this, text, args);
                    try
                    {
                        command.Invoke(context);
                    }
                    catch (System.Exception e)
                    {
                        context.Output(e.ToString());
                    }
                    Append(context.output, color);
                }
                else
                {
                    Append("コマンドが見つかりません", color);
                }
            }
        }
コード例 #2
0
        public bool Invoke(Context context)
        {
            bool ret = false;

            context.CreateOptions(options);

            if (context.argv.ContainsKey("help") == false)
            {
                ret = OnInvoke(context);
            }
            if (ret == false)
            {
                context.Output(string.Format(
                                   "コマンドの処理に失敗しました{0}",
                                   System.Environment.NewLine));
                context.Output(GetDescription(true));
            }
            return(ret);
        }