Skip to content

Commit

Permalink
Add support for specifying oblivionMods via CLI
Browse files Browse the repository at this point in the history
This is a quick untested hack that enables setting the WB root
directory (oblivionMods) through a command line argument: --bash-root
(short version -R, for ... root, idk).

Motivation is reducing reliance on bash.ini, allowing configuration to
be set at init time or through settings dict.
  • Loading branch information
BGazotti committed Mar 25, 2024
1 parent 9dfef00 commit 9ec8a51
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion Mopy/bash/barg.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def arg(group, dashed, descr, dest, action='store', dflt=None):
'Use this argument if Wrye Bash is located outside of the game '
'directory, and automatic detection failed to find it.')
arg(pathGroup, '-o', '--oblivionPath', dest='oblivionPath')

# oblivionMods #
h = ('Specify the root directory for Wrye Bash managed files.')
arg(pathGroup, '-R', '--bash-root', dest='oblivionMods')
### User Path Group ###
userPathGroup = parser.add_argument_group('User Directory Arguments',
'These arguments allow you to specify your user directories in '
Expand Down Expand Up @@ -144,6 +146,7 @@ def arg(group, dashed, descr, dest, action='store', dflt=None):
'-q': '--quiet-quit',
'-r': '--restore',
'-u': '--userPath',
'-R': '--bash-root',
}

def convert_to_long_options(sys_argv):
Expand Down
2 changes: 1 addition & 1 deletion Mopy/bash/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def _detect_game(opts, backup_bash_ini):
#--They depend on setting the bash.ini and the game
from . import initialization
game_ini_path, init_warnings = initialization.init_dirs(
opts.personalPath, opts.localAppDataPath, bush_game)
opts.personalPath, opts.localAppDataPath, bush_game, bash_root=opts.oblivionMods)
if init_warnings:
warning_msg = _('The following (non-critical) warnings were found '
'during initialization:')
Expand Down
5 changes: 3 additions & 2 deletions Mopy/bash/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _get_ini_path(ini_key, dir_key, *args):
src = 'Relative Path'
return idata_path, src

def init_dirs(personal, localAppData, game_info):
def init_dirs(personal, localAppData, game_info, bash_root=''):
"""Initialize bass.dirs dictionary. We need the bash.ini and the game
being set, so this is called upon setting the game. Global structures
that need info on Bash / Game dirs should be initialized here and set
Expand Down Expand Up @@ -219,7 +219,8 @@ def init_dirs(personal, localAppData, game_info):
dirs[u'tag_files'] = dirs[u'mods'].join(u'BashTags')
dirs[u'ini_tweaks'] = dirs[u'mods'].join(u'INI Tweaks')
#--Mod Data, Installers
oblivionMods, oblivionModsSrc = getOblivionModsPath(game_info)
oblivionMods = _get_cli_ini_path(bash_root, '-R', 'oblivionMods', game_info, getOblivionModsPath, "failed setting root","Specified bash root directory does not exist")
# oblivionMods, oblivionModsSrc = getOblivionModsPath(game_info)
dirs[u'bash_root'] = oblivionMods
deprint(f'Game Mods location set to {oblivionMods}')
dirs['modsBash'], modsBashSrc = _get_ini_path('BashModData', 'bash_root',
Expand Down

0 comments on commit 9ec8a51

Please sign in to comment.