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 17, 2024
1 parent c54aa91 commit 93da4b1
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 @@ -596,7 +596,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 @@ -104,7 +104,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 @@ -218,7 +218,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

4 comments on commit 93da4b1

@BGazotti
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Infernio this is a rather crude hack, but should be harmless and is very convenient for testing. Let me know if there's more work to be done on this front!

@BGazotti
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this does not default to gamedir/../game Mods if the specified root does not exist/is invalid, just erroring out instead. Also pending support for saving and properly retrieving root path from settings, so users won't need to pass --bash-root "whatever" every time they start WB

@Infernio
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks OK at first glance. Not sure I'll have much time for WB over the coming weeks though to review and merge it :/
@Utumno, can you take a look?

@Utumno
Copy link

@Utumno Utumno commented on 93da4b1 Mar 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will have a look asap which will probably be Tuesday though - I have also paused work on the launchers settings tab but it's not forgotten - it's just some core refactoring that has precedence and I am in the process of testing - by the way one of the regressions was in setting launchers from ini lol

Please sign in to comment.