示例#1
0
        public static void ConfigurationFile()
        {
            _colorify.Clear();

            try
            {
                Section.Header("TASK", "SERVER", "FILE");
                Section.SelectedProject();
                Section.CurrentConfiguration(_config.personal.menu.serverValidation, _config.personal.menu.serverConfiguration);

                _colorify.BlankLines();
                string dirPath = _path.Combine(Variables.Value("task_project"), _config.task.webFolder);
                dirPath.Exists("Please review your configuration file.");
                List <string> files = dirPath.Files($"*{_config.task.extension}");

                if (files.Count < 1)
                {
                    _config.personal.webServer.file = "";
                }
                else
                {
                    var i = 1;
                    foreach (var file in files)
                    {
                        string f = file;
                        _colorify.WriteLine($" {i,2}] {Transform.RemoveWords(_path.GetFileName(f), _config.task.extension)}", txtPrimary);
                        i++;
                    }
                    if (!String.IsNullOrEmpty(_config.personal.webServer.file))
                    {
                        _colorify.BlankLines();
                        _colorify.WriteLine($"{"[EMPTY] Current",82}", txtInfo);
                    }

                    Section.HorizontalRule();

                    _colorify.Write($"{" Make your choice: ",-25}", txtInfo);
                    string opt = Console.ReadLine().Trim();

                    if (!String.IsNullOrEmpty(opt))
                    {
                        Number.IsOnRange(1, Convert.ToInt32(opt), files.Count);
                        var sel = files[Convert.ToInt32(opt) - 1];
                        _config.personal.webServer.file = Transform.RemoveWords(_path.GetFileName(sel), _config.task.extension);
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(_config.personal.webServer.file))
                        {
                            Message.Error();
                        }
                    }
                }

                Menu.Status();
                Select();
            }
            catch (Exception Ex)
            {
                Exceptions.General(Ex);
            }
        }