9
9
# See https://aboutcode.org for more information about nexB OSS projects.
10
10
#
11
11
12
- from typing import Dict
12
+ from pathlib import Path
13
+ from typing import Dict , Optional
13
14
14
15
import click
15
16
@@ -43,8 +44,7 @@ def print_version(ctx, param, value):
43
44
metavar = "REQUIREMENT-FILE" ,
44
45
multiple = True ,
45
46
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." ,
48
48
)
49
49
@click .option (
50
50
"-s" ,
@@ -96,8 +96,7 @@ def print_version(ctx, param, value):
96
96
# since multiple is True, this is a sequence
97
97
default = [settings .PYPI_SIMPLE_URL ],
98
98
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." ,
101
100
)
102
101
@click .option (
103
102
"--json" ,
@@ -140,8 +139,7 @@ def print_version(ctx, param, value):
140
139
"--use-cached-index" ,
141
140
is_flag = True ,
142
141
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." ,
145
143
)
146
144
@click .option (
147
145
"--use-pypi-json-api" ,
@@ -177,7 +175,10 @@ def print_version(ctx, param, value):
177
175
help = "Show the version and exit." ,
178
176
)
179
177
@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." ,
181
182
)
182
183
@click .help_option ("-h" , "--help" )
183
184
@click .option (
@@ -187,6 +188,11 @@ def print_version(ctx, param, value):
187
188
help = "Use generic or truncated paths in the JSON output header and files sections. "
188
189
"Used only for testing to avoid absolute paths and paths changing at each run." ,
189
190
)
191
+ @click .option (
192
+ "--log-file" ,
193
+ type = click .Path (path_type = Path ),
194
+ help = "Write logs to a file." ,
195
+ )
190
196
def resolve_dependencies (
191
197
ctx ,
192
198
requirement_files ,
@@ -200,6 +206,7 @@ def resolve_dependencies(
200
206
netrc_file ,
201
207
max_rounds ,
202
208
verbose ,
209
+ log_file : Optional [Path ],
203
210
use_cached_index = False ,
204
211
use_pypi_json_api = False ,
205
212
analyze_setup_py_insecurely = False ,
@@ -240,15 +247,15 @@ def resolve_dependencies(
240
247
241
248
# Setup verbose level
242
249
if verbose >= 4 :
243
- logging .setup_logger ("DEEP" )
250
+ logging .setup_logger ("DEEP" , log_file = log_file )
244
251
elif verbose == 3 :
245
- logging .setup_logger ("TRACE" )
252
+ logging .setup_logger ("TRACE" , log_file = log_file )
246
253
elif verbose == 2 :
247
- logging .setup_logger ("DEBUG" )
254
+ logging .setup_logger ("DEBUG" , log_file = log_file )
248
255
elif verbose == 1 :
249
- logging .setup_logger ("INFO" )
256
+ logging .setup_logger ("INFO" , log_file = log_file )
250
257
else :
251
- logging .setup_logger ()
258
+ logging .setup_logger (log_file = log_file )
252
259
253
260
options = get_pretty_options (ctx , generic_paths = generic_paths )
254
261
0 commit comments