summaryrefslogtreecommitdiff
path: root/alot/__main__.py
diff options
context:
space:
mode:
authorLucas Hoffmann <l-m-h@web.de>2017-01-01 17:03:39 +0100
committerLucas Hoffmann <l-m-h@web.de>2017-01-10 12:15:20 +0100
commit125cb693518486ebd002c1e6754b27bbf7e6305d (patch)
treea8b7b40d9d7483b0bb1be460960a5484b4160930 /alot/__main__.py
parent0718b05f5ed373fe1ecc54ce338508390db2879b (diff)
Move default notmuch config path to argparse parser setup
This is only possible for the notmuch config file and not for the alot config file as the former is strictly required but the latter is not. If the latter does not exist it will be detected by the argument parser. If the former is not given on the command line the parser will return `None` and we can manually check if the default config file exists and else just skip the alot config file.
Diffstat (limited to 'alot/__main__.py')
-rw-r--r--alot/__main__.py12
1 files changed, 4 insertions, 8 deletions
diff --git a/alot/__main__.py b/alot/__main__.py
index b3a810e5..b8bb6d2c 100644
--- a/alot/__main__.py
+++ b/alot/__main__.py
@@ -25,6 +25,9 @@ def main():
parser.add_argument('-c', '--config', type=argparse.FileType('r'),
help='config file')
parser.add_argument('-n', '--notmuch-config', type=argparse.FileType('r'),
+ default=os.environ.get(
+ 'NOTMUCH_CONFIG',
+ os.path.expanduser('~/.notmuch-config')),
help='notmuch config')
parser.add_argument('-C', '--colour-mode',
choices=(1, 16, 256), type=int, default=256,
@@ -77,16 +80,9 @@ def main():
else:
alotconfig = options.config
- # locate notmuch config
- if options.notmuch_config:
- notmuchconfig = options.notmuch_config
- else:
- notmuchconfig = os.environ.get('NOTMUCH_CONFIG',
- os.path.expanduser('~/.notmuch-config'))
-
try:
settings.read_config(alotconfig)
- settings.read_notmuch_config(notmuchconfig)
+ settings.read_notmuch_config(options.notmuch_config)
except (ConfigError, OSError, IOError) as e:
sys.exit(e)