Beispiel #1
0
        private string[] ListCommandNames(string prefix, CommandListOptions options)
        {
            IList<CCommand> commands = CRegistery.ListCommands(delegate(CCommand cmd)
            {
                return !(cmd is CVarCommand) && CRegistery.ShouldListCommand(cmd, prefix, options);
            });

            return Collection.Map(commands, delegate(CCommand cmd)
            {
                return C(cmd.Name, cmd.ColorCode);
            });
        }
Beispiel #2
0
        private string[] ListCommandNames(string prefix, CommandListOptions options)
        {
            IList <CCommand> commands = CRegistery.ListCommands(delegate(CCommand cmd)
            {
                return(!(cmd is CVarCommand) && CRegistery.ShouldListCommand(cmd, prefix, options));
            });

            return(Collection.Map(commands, delegate(CCommand cmd)
            {
                return C(cmd.Name, cmd.ColorCode);
            }));
        }
Beispiel #3
0
        bool Execute(string prefix = null)
        {
            CommandListOptions options = CCommand.DefaultListOptions;

            if (includeSystem)
            {
                options |= CommandListOptions.System;
            }

            Print(ListCommandNames(prefix, options));

            return(true);
        }
Beispiel #4
0
        public static IList <string> ListVarNames(string prefix = null, CommandListOptions options = CommandListOptions.None)
        {
            IList <CVar> cvars = ListVars(ReusableLists.NextAutoRecycleList <CVar>(), prefix, options);

            string[] names = new string[cvars.Count];

            int index = 0;

            foreach (CVar cvar in cvars)
            {
                names[index++] = cvar.Name;
            }

            return(names);
        }
Beispiel #5
0
        bool Execute(string prefix = null)
        {
            CommandListOptions options = CCommand.DefaultListOptions;

            if (includeSystem)
            {
                options |= CommandListOptions.System;
            }

            // TODO: refactoring
            IList <CVar> vars = CRegistery.ListVars(prefix, options);

            if (vars.Count > 0)
            {
                if (shortList)
                {
                    string[] names = Collection.Map(vars, delegate(CVar cvar) {
                        return(StringUtils.C(cvar.Name, ColorCode.TableVar));
                    });
                    Print(names);
                }
                else
                {
                    StringBuilder result = new StringBuilder();
                    for (int i = 0; i < vars.Count; ++i)
                    {
                        CVar cvar = vars[i];
                        result.AppendFormat("  {0} {1}", StringUtils.C(cvar.Name, ColorCode.TableVar), StringUtils.Arg(cvar.Value));

                        // TODO: better color highlight
                        if (!cvar.IsDefault)
                        {
                            result.AppendFormat(" {0} {1}", StringUtils.C("default", ColorCode.TableVar), cvar.DefaultValue);
                        }

                        if (i < vars.Count - 1)
                        {
                            result.Append('\n');
                        }
                    }

                    Print(result.ToString());
                }
            }

            return(true);
        }
Beispiel #6
0
        internal static bool ShouldListCommand(CCommand cmd, string prefix, CommandListOptions options = CommandListOptions.None)
        {
            if (cmd.IsDebug && (options & CommandListOptions.Debug) == 0)
            {
                return(false);
            }

            if (cmd.IsSystem && (options & CommandListOptions.System) == 0)
            {
                return(false);
            }

            if (cmd.IsHidden && (options & CommandListOptions.Hidden) == 0)
            {
                return(false);
            }

            return(prefix == null || StringUtils.StartsWithIgnoreCase(cmd.Name, prefix));
        }
Beispiel #7
0
 internal static IList<CCommand> ListCommands(IList<CCommand> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return ListCommands(outList, delegate(CCommand cmd)
     {
         return ShouldListCommand(cmd, prefix, options);
     });
 }
Beispiel #8
0
 public static IList<CVar> ListVars(IList<CVar> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return ListVars(outList, delegate(CVarCommand cmd)
     {
         return ShouldListCommand(cmd, prefix, options);
     });
 }
Beispiel #9
0
 public static IList<CVar> ListVars(string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return ListVars(ReusableLists.NextAutoRecycleList<CVar>(), prefix, options);
 }
Beispiel #10
0
 internal static IList <CAliasCommand> ListAliases(string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return(ListAliases(ReusableLists.NextAutoRecycleList <CAliasCommand>(), prefix, options));
 }
Beispiel #11
0
        internal static IList <CAliasCommand> ListAliases(IList <CAliasCommand> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
        {
            foreach (CCommand cmd in m_commands)
            {
                CAliasCommand aliasCmd = cmd as CAliasCommand;
                if (aliasCmd != null && ShouldListCommand(aliasCmd, prefix, options))
                {
                    outList.Add(aliasCmd);
                }
            }

            return(outList);
        }
Beispiel #12
0
 public static IList <CVar> ListVars(IList <CVar> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return(ListVars(outList, delegate(CVarCommand cmd)
     {
         return ShouldListCommand(cmd, prefix, options);
     }));
 }
Beispiel #13
0
        public static IList<string> ListVarNames(string prefix = null, CommandListOptions options = CommandListOptions.None)
        {
            IList<CVar> cvars = ListVars(ReusableLists.NextAutoRecycleList<CVar>(), prefix, options);

            string[] names = new string[cvars.Count];

            int index = 0;
            foreach (CVar cvar in cvars)
            {
                names[index++] = cvar.Name;
            }

            return names;
        }
Beispiel #14
0
 public static IList <CVar> ListVars(string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return(ListVars(ReusableLists.NextAutoRecycleList <CVar>(), prefix, options));
 }
Beispiel #15
0
        internal static bool ShouldListCommand(CCommand cmd, string prefix, CommandListOptions options = CommandListOptions.None)
        {
            if (cmd.IsDebug && (options & CommandListOptions.Debug) == 0)
            {
                return false;
            }

            if (cmd.IsSystem && (options & CommandListOptions.System) == 0)
            {
                return false;
            }

            if (cmd.IsHidden && (options & CommandListOptions.Hidden) == 0)
            {
                return false;
            }

            return prefix == null || StringUtils.StartsWithIgnoreCase(cmd.Name, prefix);
        }
Beispiel #16
0
 internal static IList <CCommand> ListCommands(IList <CCommand> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return(ListCommands(outList, delegate(CCommand cmd)
     {
         return ShouldListCommand(cmd, prefix, options);
     }));
 }
Beispiel #17
0
 internal static IList<CAliasCommand> ListAliases(string prefix = null, CommandListOptions options = CommandListOptions.None)
 {
     return ListAliases(ReusableLists.NextAutoRecycleList<CAliasCommand>(), prefix, options);
 }
Beispiel #18
0
        internal static IList<CAliasCommand> ListAliases(IList<CAliasCommand> outList, string prefix = null, CommandListOptions options = CommandListOptions.None)
        {
            foreach (CCommand cmd in m_commands)
            {
                CAliasCommand aliasCmd = cmd as CAliasCommand;
                if (aliasCmd != null && ShouldListCommand(aliasCmd, prefix, options))
                {
                    outList.Add(aliasCmd);
                }
            }

            return outList;
        }