mirror of https://github.com/x89/Shreddit
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
896 B
30 lines
896 B
"""This module contains script entrypoints for shreddit.
|
|
"""
|
|
import argparse
|
|
import yaml
|
|
from shreddit.oauth import oauth_test
|
|
from shreddit.shredder import shred
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Command-line frontend to the shreddit library.")
|
|
parser.add_argument("-c", "--config", help="Config file to use instead of the default shreddit.cfg")
|
|
parser.add_argument("-p", "--praw", help="PRAW config (if not ./praw.ini)")
|
|
parser.add_argument("-t", "--test-oauth", help="Perform OAuth test and exit", action="store_true")
|
|
args = parser.parse_args()
|
|
|
|
if args.test_oauth:
|
|
oauth_test(args.praw)
|
|
return
|
|
|
|
with open(args.config or "shreddit.yml") as fh:
|
|
config = yaml.safe_load(fh)
|
|
if not config:
|
|
raise Exception("No config options passed!")
|
|
|
|
shred(config, args.praw)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|