@@ -118,20 +118,18 @@ def convert(self, value: str, param: click.Parameter | None, ctx: click.Context
118
118
def configure (ctx : click .Context , param : click .Parameter | None , filename : str | os .PathLike ) -> None :
119
119
"""Read a configuration file."""
120
120
filename = pathlib .Path (filename ).expanduser ()
121
+ msg = ''
121
122
toml_dict = {}
122
123
if filename .is_file ():
123
124
try :
124
125
with open (filename , 'rb' ) as f :
125
126
toml_dict = tomli .load (f )
126
127
except tomli .TOMLDecodeError :
127
128
msg = f'Cannot read the configuration file at { filename } '
128
- click .echo (msg )
129
129
else :
130
130
msg = f'Using configuration file at { filename } '
131
- click .echo (msg )
132
131
else :
133
132
msg = 'Not using any configuration file.'
134
- click .echo (msg )
135
133
136
134
options = {}
137
135
@@ -148,7 +146,11 @@ def configure(ctx: click.Context, param: click.Parameter | None, filename: str |
148
146
providers_dict = toml_dict .setdefault ('provider' , {})
149
147
refiners_dict = toml_dict .setdefault ('refiner' , {})
150
148
151
- ctx .obj = {'provider_configs' : providers_dict , 'refiner_configs' : refiners_dict }
149
+ ctx .obj = {
150
+ '__config__' : {'dict' : toml_dict , 'debug_message' : msg },
151
+ 'provider_configs' : providers_dict ,
152
+ 'refiner_configs' : refiners_dict ,
153
+ }
152
154
ctx .default_map = options
153
155
154
156
@@ -254,6 +256,9 @@ def subliminal(
254
256
handler .setFormatter (logging .Formatter (logging .BASIC_FORMAT ))
255
257
logging .getLogger ('subliminal' ).addHandler (handler )
256
258
logging .getLogger ('subliminal' ).setLevel (logging .DEBUG )
259
+ # log about the config file
260
+ msg = ctx .obj ['__config__' ]['debug_message' ]
261
+ logger .info (msg )
257
262
258
263
ctx .obj ['debug' ] = debug
259
264
# provider configs
0 commit comments