import os
from shutil import copy
from buildtest.config import get_default_settings
from buildtest.defaults import (
    BUILDTEST_SETTINGS_FILE,
    DEFAULT_SETTINGS_FILE,
)


def func_config_edit(args=None):
    """Edit buildtest configuration in editor. This implements ``buildtest config edit``"""

    config_opts = get_default_settings()
    os.system(f"{config_opts['config']['editor']} {BUILDTEST_SETTINGS_FILE}")


def func_config_view(args=None):
    """View buildtest configuration file. This implements ``buildtest config view``"""

    os.system(f"cat {BUILDTEST_SETTINGS_FILE}")


def func_config_reset(args=None):
    """Reset buildtest configuration by copying default configuration provided by buildtest to
       $HOME/.buildtest/settings.yml. This implements ``buildtest config reset`` command."""

    print(f"Restoring from default configuration: {DEFAULT_SETTINGS_FILE}")
    copy(DEFAULT_SETTINGS_FILE, BUILDTEST_SETTINGS_FILE)

@@ -3,16 +3,55 @@
 port os%0A
+from jsonschema import ValidationError%0A
 from shu
@@ -115,16 +115,32 @@
 settings
+, check_settings
 %0Afrom bu
@@ -392,16 +392,60 @@
 tings()%0A
+%0A    while True:%0A        success = True%0A    
     os.s
@@ -506,32 +506,264 @@
 ETTINGS_FILE%7D%22)%0A
+        try:%0A            check_settings(run_init=False)%0A        except ValidationError as err:%0A            print(err)%0A            input(%22Press any key to continue%22)%0A            success = False%0A%0A        if success:%0A            break%0A
 %0A%0Adef func_confi

make buildtest config edit to validate buildtest settings after closing file. The process (#342)