diff options
author | Tom Ryder <tom@sanctum.geek.nz> | 2024-11-17 23:16:44 +1300 |
---|---|---|
committer | Tom Ryder <tom@sanctum.geek.nz> | 2024-11-17 23:16:44 +1300 |
commit | 9fef5917a849e4d958b88d7f90f9f54b14a2b6ef (patch) | |
tree | f9a268fc9b848629569746d641f502f54d9a129c | |
parent | Add/update comments (diff) | |
download | vixf-9fef5917a849e4d958b88d7f90f9f54b14a2b6ef.tar.gz vixf-9fef5917a849e4d958b88d7f90f9f54b14a2b6ef.zip |
Handle alternative user config files
-rw-r--r-- | vixf.py3 | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -8,6 +8,7 @@ text. """ # stdlib imports +import argparse import configparser import locale import os @@ -51,13 +52,26 @@ def main(environ): Just bundle everything into a main function. """ + # Handle specifying a different user configuration file with -c or + # --config; /etc/vixf/config is always read + parser = argparse.ArgumentParser( + prog=SELF, + description='Edit contents of text fields in a text editor', + ) + parser.add_argument( + '-c', '--config', + help='path to user config file', + default=os.path.expanduser(f'~/.config/{SELF}/config'), + ) + args = parser.parse_args() + # Read config; read /etc/vixf/config first, then ~/.vixf/config, if they # exist. It's not an error if they don't. config = configparser.ConfigParser() config.read( [ f'/etc/{SELF}/config', - os.path.expanduser(f'~/.config/{SELF}/config'), + args.config, ], encoding=locale.getpreferredencoding(), ) |