@@ -142,7 +142,10 @@ def __init__(
142142 # this parallel config exists to
143143 # * compare with my.cnf
144144 # * support the --checkup feature
145+ # todo: after removing my.cnf, create the parallel configs only when --checkup is set
145146 self .config_without_package_defaults = read_config_files (config_files , ignore_package_defaults = True )
147+ # this parallel config exists to compare with my.cnf support the --checkup feature
148+ self .config_without_user_options = read_config_files (config_files , ignore_user_options = True )
146149 self .multi_line = c ["main" ].as_bool ("multi_line" )
147150 self .key_bindings = c ["main" ]["key_bindings" ]
148151 special .set_timing_enabled (c ["main" ].as_bool ("timing" ))
@@ -2272,28 +2275,72 @@ def read_ssh_config(ssh_config_path: str):
22722275
22732276
22742277def do_config_checkup (mycli : MyCli ) -> None :
2275- did_output = False
2278+ did_output_missing = False
2279+ did_output_unsupported = False
2280+ did_output_deprecated = False
2281+
2282+ indent = ' '
2283+ transitions = {
2284+ f'{ indent } [main]\n { indent } default_character_set' : f'{ indent } [connection]\n { indent } default_character_set' ,
2285+ f'{ indent } [main]\n { indent } ssl_mode' : f'{ indent } [connection]\n { indent } default_ssl_mode' ,
2286+ }
22762287
22772288 if not list (mycli .config .keys ()):
22782289 print ('\n The local ~/,myclirc is missing or empty.\n ' )
2279- did_output = True
2290+ did_output_missing = True
22802291 else :
2281- for section_name in mycli .config . keys () :
2292+ for section_name in mycli .config :
22822293 if section_name not in mycli .config_without_package_defaults :
2283- if not did_output :
2284- print ('\n Missing in user ~/.myclirc:\n ' )
2285- print (f'The entire section:\n \n [{ section_name } ]\n ' )
2286- did_output = True
2294+ if not did_output_missing :
2295+ print ('\n ### Missing in user ~/.myclirc:\n ' )
2296+ print (f'The entire section:\n \n { indent } [{ section_name } ]\n ' )
2297+ did_output_missing = True
22872298 continue
22882299 for item_name in mycli .config [section_name ]:
22892300 if item_name not in mycli .config_without_package_defaults [section_name ]:
2290- if not did_output :
2291- print ('\n Missing in user ~/.myclirc:\n ' )
2292- print (f'The item:\n \n [{ section_name } ]\n { item_name } =\n ' )
2293- did_output = True
2294- if did_output :
2301+ if not did_output_missing :
2302+ print ('\n ### Missing in user ~/.myclirc:\n ' )
2303+ print (f'The item:\n \n { indent } [{ section_name } ]\n { indent } { item_name } =\n ' )
2304+ did_output_missing = True
2305+
2306+ for section_name in mycli .config_without_package_defaults :
2307+ if section_name not in mycli .config_without_user_options :
2308+ if not did_output_unsupported :
2309+ print ('\n ### Unsupported in user ~/.myclirc:\n ' )
2310+ did_output_unsupported = True
2311+ print (f'The entire section:\n \n { indent } [{ section_name } ]\n ' )
2312+ continue
2313+ for item_name in mycli .config_without_package_defaults [section_name ]:
2314+ if section_name == 'colors' and item_name .startswith ('sql.' ):
2315+ # these are commented out in the package myclirc
2316+ continue
2317+ transition_key = f'{ indent } [{ section_name } ]\n { indent } { item_name } '
2318+ if transition_key in transitions :
2319+ continue
2320+ if item_name not in mycli .config_without_user_options [section_name ]:
2321+ if not did_output_unsupported :
2322+ print ('\n ### Unsupported in user ~/.myclirc:\n ' )
2323+ print (f'The item:\n \n { indent } [{ section_name } ]\n { indent } { item_name } =\n ' )
2324+ did_output_unsupported = True
2325+
2326+ for section_name in mycli .config_without_package_defaults :
2327+ if section_name not in mycli .config_without_user_options :
2328+ continue
2329+ for item_name in mycli .config_without_package_defaults [section_name ]:
2330+ if section_name == 'colors' and item_name .startswith ('sql.' ):
2331+ # these are commented out in the package myclirc
2332+ continue
2333+ transition_key = f'{ indent } [{ section_name } ]\n { indent } { item_name } '
2334+ if transition_key in transitions :
2335+ if not did_output_deprecated :
2336+ print ('\n ### Deprecated in user ~/.myclirc:\n ' )
2337+ transition_value = transitions [transition_key ]
2338+ print (f'It is recommended to transition:\n \n { transition_key } \n \n to\n \n { transition_value } \n ' )
2339+ did_output_deprecated = True
2340+
2341+ if did_output_missing or did_output_unsupported or did_output_deprecated :
22952342 print (
2296- 'For more info on new features, see the commentary and defaults at:\n \n * https://github.com/dbcli/mycli/blob/main/mycli/myclirc\n '
2343+ 'For more info on supported features, see the commentary and defaults at:\n \n * https://github.com/dbcli/mycli/blob/main/mycli/myclirc\n '
22972344 )
22982345 else :
22992346 print ('User configuration all up to date!' )
0 commit comments