@@ -37,6 +37,39 @@ def main(args=None, steam_path=None, steam_root=None):
37
37
"""
38
38
'protontricks' script entrypoint
39
39
"""
40
+ def _find_proton_app_or_exit (steam_path , steam_apps , appid ):
41
+ """
42
+ Attempt to find a Proton app. Fail with an appropriate CLI error
43
+ message if one cannot be found.
44
+ """
45
+ proton_app = find_proton_app (
46
+ steam_path = steam_path , steam_apps = steam_apps , appid = appid
47
+ )
48
+
49
+ if not proton_app :
50
+ if os .environ .get ("PROTON_VERSION" ):
51
+ # Print an error listing accepted values if PROTON_VERSION was
52
+ # set, as the user is trying to use a certain Proton version
53
+ proton_names = sorted (set ([
54
+ app .name for app in steam_apps if app .is_proton
55
+ ]))
56
+ exit_ (
57
+ "Protontricks installation could not be found with given "
58
+ "$PROTON_VERSION!\n \n "
59
+ f"Valid values include: { ', ' .join (proton_names )} "
60
+ )
61
+ else :
62
+ exit_ ("Proton installation could not be found!" )
63
+
64
+ if not proton_app .is_proton_ready :
65
+ exit_ (
66
+ "Proton installation is incomplete. Have you launched a Steam "
67
+ "app using this Proton version at least once to finish the "
68
+ "installation?"
69
+ )
70
+
71
+ return proton_app
72
+
40
73
if args is None :
41
74
args = sys .argv [1 :]
42
75
@@ -297,19 +330,9 @@ def exit_(error):
297
330
cwd = str (steam_app .install_path ) if args .cwd_app else None
298
331
299
332
# 6. Find Proton version of selected app
300
- proton_app = find_proton_app (
333
+ proton_app = _find_proton_app_or_exit (
301
334
steam_path = steam_path , steam_apps = steam_apps , appid = steam_app .appid
302
335
)
303
- if not proton_app :
304
- exit_ ("Proton installation could not be found!" )
305
-
306
- if not proton_app .is_proton_ready :
307
- exit_ (
308
- "Proton installation is incomplete. Have you launched a Steam "
309
- "app using this Proton version at least once to finish the "
310
- "installation?"
311
- )
312
-
313
336
314
337
run_command (
315
338
winetricks_path = winetricks_path ,
@@ -361,19 +384,9 @@ def exit_(error):
361
384
return
362
385
363
386
# 6. Find globally active Proton version now
364
- proton_app = find_proton_app (
387
+ proton_app = _find_proton_app_or_exit (
365
388
steam_path = steam_path , steam_apps = steam_apps , appid = args .appid )
366
389
367
- if not proton_app :
368
- exit_ ("Proton installation could not be found!" )
369
-
370
- if not proton_app .is_proton_ready :
371
- exit_ (
372
- "Proton installation is incomplete. Have you launched a Steam app "
373
- "using this Proton version at least once to finish the "
374
- "installation?"
375
- )
376
-
377
390
# If neither search or GUI are set, do a normal Winetricks command
378
391
# Find game by appid
379
392
steam_appid = int (args .appid )
0 commit comments