Exemplo n.º 1
0
        bool Execute(string filename)
        {
            try
            {
                if (edit)
                {
                    string configPath = CConfigHelper.GetConfigPath(filename);
                    if (!CFileUtils.FileExists(configPath))
                    {
                        PrintError("File does not exist: {0}", configPath);
                        return(false);
                    }

                    EditorUtility.OpenWithDefaultApp(configPath);
                    return(true);
                }

                IList <string> lines = CConfigHelper.ReadConfig(filename);
                foreach (string line in lines)
                {
                    PrintIndent(line);
                }

                return(true);
            }
            catch (Exception e)
            {
                PrintIndent("Can't read config: {0}", e.Message);
                return(false);
            }
        }
Exemplo n.º 2
0
        bool Execute(string filename)
        {
            IList <string> lines = new List <string>();

            // cvars
            AddEntries(lines, ListCvars(), "cvars");

            // bindings
            AddEntries(lines, ListBindings(), "bindings");

            // aliases
            AddEntries(lines, ListAliases(), "aliases");

            try
            {
                CConfigHelper.WriteConfig(filename, lines);
                return(true);
            }
            catch (Exception e)
            {
                if (this.IsManualMode)
                {
                    PrintError("Can't write config: " + e.Message);
                }
            }

            return(false);
        }
Exemplo n.º 3
0
        bool Execute(string filename)
        {
            try
            {
                IList <string> lines = CConfigHelper.ReadConfig(filename);
                foreach (string line in lines)
                {
                    string trim = line.Trim();
                    if (trim.Length == 0 || trim.StartsWith("//"))
                    {
                        continue;
                    }

                    ExecCommand(line);
                }

                PostNotification(CCommandNotifications.ConfigLoaded);

                return(true);
            }
            catch (Exception e)
            {
                if (this.IsManualMode)
                {
                    PrintError("Can't load config: {0}", e);
                }

                return(false);
            }
        }
Exemplo n.º 4
0
        protected override IList <string> AutoCompleteArgs(string commandLine, string token) // TODO: better autocompletion
        {
            List <string> configs = new List <string>(CConfigHelper.ListConfigs(token));

            // TODO: refactor this
            if (!configs.Contains(CConstants.ConfigDefault))
            {
                configs.Add(CConstants.ConfigDefault);
            }
            if (!configs.Contains(CConstants.ConfigAutoExec))
            {
                configs.Add(CConstants.ConfigAutoExec);
            }
            if (!configs.Contains(CConstants.ConfigPlayMode))
            {
                configs.Add(CConstants.ConfigPlayMode);
            }

            return(CStringUtils.Filter(configs, token));
        }
Exemplo n.º 5
0
 protected override IList <string> AutoCompleteArgs(string commandLine, string token)
 {
     return(CConfigHelper.ListConfigs(token));
 }