Skip to content

Commit

Permalink
Allow overriding directories via args
Browse files Browse the repository at this point in the history
You can now specify directories via args when calling ammo from bash.
All of these arguments are optional.

`--downloads`
    this defaults to `~/Downloads`

`--conf`
    this defaults to `~/.local/share/ammo`.
    If you are overriding this, note that this is the configuration
    for ALL games, not just one. Ammo will still make/expect
    game-specific folders under this directory, and conf for each game
    will be stored inside of that game's folder.

`--mods`
    this defaults to `~/.local/share/ammo/<game name>/mods`.
    If you are overriding this, note that this is the directory that
    contains the actual source files of mods for a specific game. Due to
    the way ammo uses symlinks, it is not recommended to toggle this
    back and forth when running against the same game, as ammo will
    detect when a game's symlinks don't point back to source files in
    this folder (which will cause it to deactivate mods you had
    previously configured).

    I do not recommend using ammo alongside another mod organizer, but I
    suppose this might be useful in those cases.

With these changes, you can now get some semblance of profile support
(though if you're switching between profiles, you will need to
reactivate your mods and plugins then commit):

- Manage all games with default profile:
    `ammo`
- Manage all games with arbitrary profile:
    `ammo --conf Documents/ammo_alt_profile`
  • Loading branch information
cyberrumor committed Mar 9, 2024
1 parent 1fc3021 commit 087b45c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 5 deletions.
10 changes: 6 additions & 4 deletions ammo/game_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class GameController(Controller):
with the selected game and runs it under the UI.
"""

def __init__(self):
def __init__(self, args):
self.args = args
self.ids = {
"Skyrim Special Edition": "489830",
"Oblivion": "22330",
Expand All @@ -43,7 +44,8 @@ def __init__(self):
"Enderal Special Edition": "976620",
"Starfield": "1716740",
}
self.downloads = Path.home() / "Downloads"
self.downloads = self.args.downloads.resolve(strict=True)

self.steam = Path.home() / ".local/share/Steam/steamapps"
self.flatpak = (
Path.home()
Expand Down Expand Up @@ -139,8 +141,8 @@ def _manage_game(self, index: int) -> None:
)
data = directory / "Data"

ammo_conf_dir = Path.home() / f".local/share/ammo/{game_selection.name}"
ammo_mods_dir = ammo_conf_dir / "mods"
ammo_conf_dir = self.args.conf.resolve() / game_selection.name
ammo_mods_dir = (self.args.mods or ammo_conf_dir / "mods").resolve()
ammo_conf = ammo_conf_dir / "ammo.conf"

match game_selection.name:
Expand Down
32 changes: 31 additions & 1 deletion bin/ammo
Original file line number Diff line number Diff line change
@@ -1,7 +1,37 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path

from ammo.game_controller import GameController
from ammo.ui import UI

controller = GameController()
parser = argparse.ArgumentParser(description="Manage mods for Bethesda games.")

parser.add_argument(
"--downloads",
default=Path.home() / "Downloads",
metavar="PATH",
help="directory containing installable archives",
type=Path,
)

parser.add_argument(
"--conf",
default=Path.home() / ".local/share/ammo",
metavar="PATH",
help="directory containing configs for managed games",
type=Path,
)

parser.add_argument(
"--mods",
metavar="PATH",
help="directory containing mods for this session",
type=Path,
)

args = parser.parse_args()

controller = GameController(args)
ui = UI(controller)
ui.repl()

0 comments on commit 087b45c

Please sign in to comment.