11# # keep this in sync with types.nim Config def
22# # a file with config code for the c backend, used mostly by ui_data for repl/tests
33
4- import json_serialization/ std/ tables, strutils, sequtils, os, yaml, std/ streams
4+ import json_serialization/ std/ tables, strutils, sequtils, os, yaml, std / [ streams, strformat]
55import .. / common / [types, paths]
66
77type
@@ -139,7 +139,7 @@ proc loadConfig*(folder: string, inTest: bool): Config =
139139 if file.len == 0 :
140140 file = userConfigDir / configPath
141141 createDir (userConfigDir)
142- copyFile (configDir / defaultConfigPath, userConfigDir / configPath )
142+ copyFile (configDir / defaultConfigPath, file )
143143 # if inTest:
144144 # file = codetracerTestDir / testConfigPath
145145 var raw = " "
@@ -160,6 +160,15 @@ proc loadConfig*(folder: string, inTest: bool): Config =
160160 except Exception as e:
161161 echo " ERROR: loading config: " , e.msg
162162 echo " if the schema has changed, and you have an existing config file, you might get an error here"
163- echo " you can manually adapt your config file or"
164- echo " you can reset it by deleting $HOME/.config/codetracer/.config.yaml"
165- quit (1 )
163+ # echo " you can manually adapt your config file or"
164+ # echo " you can reset it by deleting $HOME/.config/codetracer/.config.yaml"
165+ let backupFilePath = userConfigDir / " backup_config.yaml"
166+ createDir (userConfigDir)
167+ try :
168+ copyFile (file, backupFilePath)
169+ echo fmt" for now we now have directly copied your existing config file to { backupFilePath} "
170+ except Exception as copyError:
171+ echo " ERROR: couldn't backup your existing config file; error: " , copyError.msg
172+ copyFile (configDir / defaultConfigPath, file)
173+ echo " REPLACED with new up to date default config file"
174+
0 commit comments