From: Simon Tatham Date: Sat, 9 Dec 2023 15:42:44 +0000 (+0000) Subject: Override for config directory. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=228d219c3c22e8d8cb09cb023d3606b20b2891e2;p=mastodonochrome.git Override for config directory. This provides a crude means of managing multiple accounts. At the moment my only use case for this is logging in to a test server so that I can test the fine points of posting without making a fool of myself on the live fediverse. So I don't need to run the accounts in parallel in a user-friendly way, and I can easily just pass a weird command-line option when I'm doing testing. --- diff --git a/login.py b/login.py index 8ed54ea..48a2212 100644 --- a/login.py +++ b/login.py @@ -3,7 +3,10 @@ import json import os import xdg +override_config_dir = None def config_dir(): + if override_config_dir is not None: + return override_config_dir try: config_home = xdg.XDG_CONFIG_HOME except AttributeError: diff --git a/mastodonochrome b/mastodonochrome index 9c1330a..301b4bc 100755 --- a/mastodonochrome +++ b/mastodonochrome @@ -99,9 +99,12 @@ def main(): "HTTP retrievals.") parser.add_argument("--login", action="store_const", dest="action", const=login.LoginUI, help="Log in to a user account.") + parser.add_argument("--config", help="Alternative config directory.") parser.set_defaults(action=cursesclient.CursesUI) args = parser.parse_args() + login.override_config_dir = args.config + if args.test is not None: return unittest.main(argv=[sys.argv[0]] + args.test, testLoader=MyTestLoader())