Skip to content

Commit 08d596a

Browse files
committed
Default to GUI if no args provided
Default to GUI (i.e. set `--gui` flag) if no command-line arguments are provided. Fixes #333
1 parent 8ddcbed commit 08d596a

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1111

1212
### Changed
1313
- `protontricks -c` and `protontricks-launch` now use the current working directory instead of the game's installation directory. `--cwd-app` can be used to restore old behavior. Scripts can also `$STEAM_APP_PATH` environment variable to determine the game's installation directory; this has been supported (albeit undocumented) since 1.8.0.
14+
- `protontricks` will now launch GUI if no arguments were provided
1415

1516
## [1.11.1] - 2024-02-20
1617
### Fixed

src/protontricks/cli/main.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def main(args=None, steam_path=None, steam_root=None):
156156

157157
args = parser.parse_args(args)
158158

159+
if len(sys.argv) < 2:
160+
# No arguments were provided, default to GUI
161+
args.gui = True
162+
159163
# 'cli_error_handler' relies on this to know whether to use error dialog or
160164
# not
161165
main.no_term = args.no_term

tests/cli/test_main.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import sys
23
import shutil
34
from pathlib import Path
45

@@ -334,15 +335,6 @@ def test_run_winetricks_game_not_found(
334335

335336
assert "Steam app with the given app ID could not be found" in result
336337

337-
def test_run_no_command(self, cli):
338-
"""
339-
Run only the 'protontricks' command.
340-
"""
341-
result = cli([])
342-
343-
# Help will be printed if no specific command is given
344-
assert result.startswith("usage: ")
345-
346338
@pytest.mark.usefixtures("default_proton")
347339
def test_run_returncode_passed(self, cli, steam_app_factory):
348340
"""
@@ -780,6 +772,23 @@ def test_run_gui_proton_incomplete(
780772

781773
assert "Proton installation is incomplete" in result
782774

775+
@pytest.mark.usefixtures("default_proton", "gui_provider")
776+
def test_run_no_args(
777+
self, cli, steam_app_factory, command_mock, gui_provider,
778+
monkeypatch):
779+
"""
780+
Run only the 'protontricks' command. This will default to GUI.
781+
"""
782+
# Monkeypatch 'sys.argv', as that seems to be the only way to determine
783+
# whether no arguments were provided
784+
monkeypatch.setattr(sys, "argv", ["protontricks"])
785+
steam_app_factory(name="Fake game", appid=10)
786+
787+
result = cli([], expect_returncode=1)
788+
789+
# Help will be printed if no specific command is given
790+
assert "No game was selected" in result
791+
783792

784793
class TestCLICommand:
785794
def test_run_command(

0 commit comments

Comments
 (0)