Skip to content

Commit

Permalink
Optionally skip game selection menu (#72)
Browse files Browse the repository at this point in the history
Add a new argument `--title` which will skip the game selection menu if
the given title is present by automatically managing that title.

Usage:
    `ammo --title "Skyrim Special Edition"`

Configure an alias in ~/.bashrc if this is the only title you will ever
want to manage with ammo.
  • Loading branch information
cyberrumor committed Dec 17, 2024
1 parent 4661c85 commit b930e02
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ammo/bin/ammo
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ parser.add_argument(
type=Path,
)

parser.add_argument(
"--title",
default="",
type=str,
metavar="TITLE",
help="manage a detected game with TITLE (skip game selection menu)",
)

args = parser.parse_args()

controller = GameController(args)
Expand Down
8 changes: 8 additions & 0 deletions ammo/controller/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,14 @@ def __init__(self, args):
)
elif len(self.games) == 1:
self.manage_game(0)
elif args.title:
if args.title in [i.name for i in self.games]:
index = [i.name for i in self.games].index(args.title)
self.manage_game(index)
else:
raise ValueError(
f"Could not find {args.title=} in {[i.name for i in self.games]}"
)
else:
self.populate_index_commands()

Expand Down

0 comments on commit b930e02

Please sign in to comment.