private string[] ListCommandNames(string prefix, CCommandListOptions options) { IList <CCommand> commands = CRegistery.ListCommands(delegate(CCommand cmd) { return(!(cmd is CVarCommand) && CRegistery.ShouldListCommand(cmd, prefix, options)); }); return(CCollection.Map(commands, delegate(CCommand cmd) { return C(cmd.Name, cmd.ColorCode); })); }
bool Execute(string prefix = null) { CCommandListOptions options = CCommand.DefaultListOptions; if (includeSystem) { options |= CCommandListOptions.System; } Print(ListCommandNames(prefix, options)); return(true); }
public static IList <string> ListVarNames(string prefix = null, CCommandListOptions options = CCommandListOptions.None) { IList <CVar> cvars = ListVars(new List <CVar>(), prefix, options); string[] names = new string[cvars.Count]; int index = 0; foreach (CVar cvar in cvars) { names[index++] = cvar.Name; } return(names); }
bool Execute(string prefix = null) { CCommandListOptions options = CCommand.DefaultListOptions; if (includeSystem) { options |= CCommandListOptions.System; } // TODO: refactoring IList <CVar> vars = CRegistery.ListVars(prefix, options); if (vars.Count > 0) { if (shortList) { string[] names = CCollection.Map(vars, delegate(CVar cvar) { return(CStringUtils.C(cvar.Name, CColorCode.TableVar)); }); Print(names); } else { StringBuilder result = new StringBuilder(); for (int i = 0; i < vars.Count; ++i) { CVar cvar = vars[i]; result.AppendFormat(" {0} {1}", CStringUtils.C(cvar.Name, CColorCode.TableVar), CStringUtils.Arg(cvar.Value)); // TODO: better color highlight if (!cvar.IsDefault) { result.AppendFormat(" {0} {1}", CStringUtils.C("default", CColorCode.TableVar), cvar.DefaultValue); } if (i < vars.Count - 1) { result.Append('\n'); } } Print(result.ToString()); } } return(true); }
internal static bool ShouldListCommand(CCommand cmd, string prefix, CCommandListOptions options = CCommandListOptions.None) { if (cmd.IsDebug && (options & CCommandListOptions.Debug) == 0) { return(false); } if (cmd.IsSystem && (options & CCommandListOptions.System) == 0) { return(false); } if (cmd.IsHidden && (options & CCommandListOptions.Hidden) == 0) { return(false); } return(prefix == null || CStringUtils.StartsWithIgnoreCase(cmd.Name, prefix)); }
internal static IList <CAliasCommand> ListAliases(IList <CAliasCommand> outList, string prefix = null, CCommandListOptions options = CCommandListOptions.None) { foreach (CCommand cmd in m_commands) { CAliasCommand aliasCmd = cmd as CAliasCommand; if (aliasCmd != null && ShouldListCommand(aliasCmd, prefix, options)) { outList.Add(aliasCmd); } } return(outList); }
internal static IList <CAliasCommand> ListAliases(string prefix = null, CCommandListOptions options = CCommandListOptions.None) { return(ListAliases(new List <CAliasCommand>(), prefix, options)); }
public static IList <CVar> ListVars(IList <CVar> outList, string prefix = null, CCommandListOptions options = CCommandListOptions.None) { return(ListVars(outList, delegate(CVarCommand cmd) { return ShouldListCommand(cmd, prefix, options); })); }
public static IList <CVar> ListVars(string prefix = null, CCommandListOptions options = CCommandListOptions.None) { return(ListVars(new List <CVar>(), prefix, options)); }
internal static IList <CCommand> ListCommands(IList <CCommand> outList, string prefix = null, CCommandListOptions options = CCommandListOptions.None) { return(ListCommands(outList, delegate(CCommand cmd) { return ShouldListCommand(cmd, prefix, options); })); }