bool Execute(string filename) { IList <string> lines = ReusableLists.NextAutoRecycleList <string>(); // cvars AddEntries(lines, ListCvars(), "cvars"); // bindings AddEntries(lines, ListBindings(), "bindings"); // aliases AddEntries(lines, ListAliases(), "aliases"); try { ConfigHelper.WriteConfig(filename, lines); return(true); } catch (Exception e) { if (this.IsManualMode) { PrintError("Can't write config: " + e.Message); } } return(false); }
internal IList <Option> ListOptions(string prefix = null) { return(ListOptions(ReusableLists.NextAutoRecycleList <Option>(), prefix)); }
private bool ExecuteGuarded(IList <string> tokens, string commandLine = null) { ResetOptions(); Iterator <string> iter = new Iterator <string>(tokens); iter.Next(); // first token is a command name if (this.IsManualMode) { PrintPrompt(commandLine); } if (this.IsPlayModeOnly && !Runtime.IsPlaying) { PrintError("Command is available in the play mode only"); return(false); } ReusableList <string> argsList = ReusableLists.NextAutoRecycleList <string>(); while (iter.HasNext()) { string token = StringUtils.UnArg(iter.Next()); // first, try to parse options if (!TryParseOption(iter, token)) { // consume the rest of the args argsList.Add(token); while (iter.HasNext()) { token = StringUtils.UnArg(iter.Next()); argsList.Add(token); } break; } } if (m_values != null) { if (argsList.Count != 1) { PrintError("Unexpected arguments count {0}", argsList.Count); PrintUsage(); return(false); } string arg = argsList[0]; if (Array.IndexOf(m_values, arg) == -1) { PrintError("Unexpected argument '{0}'", arg); PrintUsage(); return(false); } } if (m_options != null) { for (int i = 0; i < m_options.Count; ++i) { Option opt = m_options[i]; if (opt.IsRequired && !opt.IsHandled) { PrintError("Missing required option --{0}{1}", opt.Name, opt.ShortName != null ? "(-" + opt.ShortName + ")" : ""); PrintUsage(); return(false); } } } string[] args = argsList.Count > 0 ? argsList.ToArray() : EMPTY_COMMAND_ARGS; MethodInfo executeMethod = resolveExecuteMethod(args); if (executeMethod == null) { PrintError("Wrong arguments"); PrintUsage(); return(false); } return(CCommandUtils.Invoke(this, executeMethod, args)); }
internal static IList <LogLevel> ListLevels() { return(ListLevels(ReusableLists.NextAutoRecycleList <LogLevel>())); }
internal static IList <Tag> ListTags() { return(ListTags(ReusableLists.NextAutoRecycleList <Tag>())); }