Skip to content

Commit

Permalink
Default to GUI if no args provided
Browse files Browse the repository at this point in the history
Default to GUI (i.e. set `--gui` flag) if no command-line arguments
are provided.

Fixes #333
  • Loading branch information
Matoking committed Sep 11, 2024
1 parent 8ddcbed commit 08d596a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

### Changed
- `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.
- `protontricks` will now launch GUI if no arguments were provided

## [1.11.1] - 2024-02-20
### Fixed
Expand Down
4 changes: 4 additions & 0 deletions src/protontricks/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@ def main(args=None, steam_path=None, steam_root=None):

args = parser.parse_args(args)

if len(sys.argv) < 2:
# No arguments were provided, default to GUI
args.gui = True

# 'cli_error_handler' relies on this to know whether to use error dialog or
# not
main.no_term = args.no_term
Expand Down
27 changes: 18 additions & 9 deletions tests/cli/test_main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import shutil
from pathlib import Path

Expand Down Expand Up @@ -334,15 +335,6 @@ def test_run_winetricks_game_not_found(

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

def test_run_no_command(self, cli):
"""
Run only the 'protontricks' command.
"""
result = cli([])

# Help will be printed if no specific command is given
assert result.startswith("usage: ")

@pytest.mark.usefixtures("default_proton")
def test_run_returncode_passed(self, cli, steam_app_factory):
"""
Expand Down Expand Up @@ -780,6 +772,23 @@ def test_run_gui_proton_incomplete(

assert "Proton installation is incomplete" in result

@pytest.mark.usefixtures("default_proton", "gui_provider")
def test_run_no_args(
self, cli, steam_app_factory, command_mock, gui_provider,
monkeypatch):
"""
Run only the 'protontricks' command. This will default to GUI.
"""
# Monkeypatch 'sys.argv', as that seems to be the only way to determine
# whether no arguments were provided
monkeypatch.setattr(sys, "argv", ["protontricks"])
steam_app_factory(name="Fake game", appid=10)

result = cli([], expect_returncode=1)

# Help will be printed if no specific command is given
assert "No game was selected" in result


class TestCLICommand:
def test_run_command(
Expand Down

0 comments on commit 08d596a

Please sign in to comment.