chiark / gitweb /
Override for config directory.
authorSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 15:42:44 +0000 (15:42 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 9 Dec 2023 15:57:00 +0000 (15:57 +0000)
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.

login.py
mastodonochrome

index 8ed54eabc36c41928ab3a7dd2054ec99c81d0d9d..48a2212cf85df2d7d9498f8197cb41efc070e40d 100644 (file)
--- 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:
index 9c1330a7ba122922f6144d5382995ae41b437e31..301b4bcdd6fbc78d25facb930513ab9a8d5de86b 100755 (executable)
@@ -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())