99# See https://aboutcode.org for more information about nexB OSS projects.
1010#
1111
12- from typing import Dict
12+ from pathlib import Path
13+ from typing import Dict , Optional
1314
1415import click
1516
@@ -43,8 +44,7 @@ def print_version(ctx, param, value):
4344 metavar = "REQUIREMENT-FILE" ,
4445 multiple = True ,
4546 required = False ,
46- help = "Path to pip requirements file listing thirdparty packages. "
47- "This option can be used multiple times." ,
47+ help = "Path to pip requirements file listing thirdparty packages. This option can be used multiple times." ,
4848)
4949@click .option (
5050 "-s" ,
@@ -96,8 +96,7 @@ def print_version(ctx, param, value):
9696 # since multiple is True, this is a sequence
9797 default = [settings .PYPI_SIMPLE_URL ],
9898 multiple = True ,
99- help = "PyPI simple index URL(s) to use in order of preference. "
100- "This option can be used multiple times." ,
99+ help = "PyPI simple index URL(s) to use in order of preference. This option can be used multiple times." ,
101100)
102101@click .option (
103102 "--json" ,
@@ -140,8 +139,7 @@ def print_version(ctx, param, value):
140139 "--use-cached-index" ,
141140 is_flag = True ,
142141 hidden = True ,
143- help = "Use cached on-disk PyPI simple package indexes "
144- "and do not refetch package index if cache is present." ,
142+ help = "Use cached on-disk PyPI simple package indexes and do not refetch package index if cache is present." ,
145143)
146144@click .option (
147145 "--use-pypi-json-api" ,
@@ -177,7 +175,10 @@ def print_version(ctx, param, value):
177175 help = "Show the version and exit." ,
178176)
179177@click .option (
180- "--ignore-errors" , is_flag = True , default = False , help = "Ignore errors and continue execution."
178+ "--ignore-errors" ,
179+ is_flag = True ,
180+ default = False ,
181+ help = "Ignore errors and continue execution." ,
181182)
182183@click .help_option ("-h" , "--help" )
183184@click .option (
@@ -187,6 +188,11 @@ def print_version(ctx, param, value):
187188 help = "Use generic or truncated paths in the JSON output header and files sections. "
188189 "Used only for testing to avoid absolute paths and paths changing at each run." ,
189190)
191+ @click .option (
192+ "--log-file" ,
193+ type = click .Path (path_type = Path ),
194+ help = "Write logs to a file." ,
195+ )
190196def resolve_dependencies (
191197 ctx ,
192198 requirement_files ,
@@ -200,6 +206,7 @@ def resolve_dependencies(
200206 netrc_file ,
201207 max_rounds ,
202208 verbose ,
209+ log_file : Optional [Path ],
203210 use_cached_index = False ,
204211 use_pypi_json_api = False ,
205212 analyze_setup_py_insecurely = False ,
@@ -240,15 +247,15 @@ def resolve_dependencies(
240247
241248 # Setup verbose level
242249 if verbose >= 4 :
243- logging .setup_logger ("DEEP" )
250+ logging .setup_logger ("DEEP" , log_file = log_file )
244251 elif verbose == 3 :
245- logging .setup_logger ("TRACE" )
252+ logging .setup_logger ("TRACE" , log_file = log_file )
246253 elif verbose == 2 :
247- logging .setup_logger ("DEBUG" )
254+ logging .setup_logger ("DEBUG" , log_file = log_file )
248255 elif verbose == 1 :
249- logging .setup_logger ("INFO" )
256+ logging .setup_logger ("INFO" , log_file = log_file )
250257 else :
251- logging .setup_logger ()
258+ logging .setup_logger (log_file = log_file )
252259
253260 options = get_pretty_options (ctx , generic_paths = generic_paths )
254261
0 commit comments