aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2024-11-17 23:16:44 +1300
committerTom Ryder <tom@sanctum.geek.nz>2024-11-17 23:16:44 +1300
commit9fef5917a849e4d958b88d7f90f9f54b14a2b6ef (patch)
treef9a268fc9b848629569746d641f502f54d9a129c
parentAdd/update comments (diff)
downloadvixf-9fef5917a849e4d958b88d7f90f9f54b14a2b6ef.tar.gz
vixf-9fef5917a849e4d958b88d7f90f9f54b14a2b6ef.zip
Handle alternative user config files
-rw-r--r--vixf.py316
1 files changed, 15 insertions, 1 deletions
diff --git a/vixf.py3 b/vixf.py3
index d7a7ad2..55343ca 100644
--- a/vixf.py3
+++ b/vixf.py3
@@ -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(),
)