diff --git a/requirements.txt b/requirements.txt index 56c70cd..1dfc88e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ backports-abc==0.4 tornado==4.3 update-checker==0.15 wheel==0.24.0 +appdirs==1.4.3 diff --git a/shreddit/app.py b/shreddit/app.py index 82521da..d98b4c1 100644 --- a/shreddit/app.py +++ b/shreddit/app.py @@ -5,6 +5,7 @@ import yaml import logging import os import pkg_resources +from appdirs import user_config_dir from shreddit import default_config from shreddit.shredder import Shredder @@ -28,7 +29,15 @@ def main(): fout.write(pkg_resources.resource_string("shreddit", "praw.ini.example")) return - config_filename = args.config or "shreddit.yml" + config_dir = user_config_dir("shreddit/shreddit.yml") + + if args.config: + config_filename = args.config + elif os.path.exists(config_dir): + config_filename = config_dir + else: + config_filename = "shreddit.yml" + if not os.path.isfile(config_filename): print("No shreddit configuration file was found or provided. Run this script with -g to generate one.") return