From a00e703068c882c867449ba3b8d8e7831e3b47b1 Mon Sep 17 00:00:00 2001 From: Ronald Schaten Date: Sun, 31 Oct 2010 19:46:13 +0100 Subject: [PATCH] command line arguments to select action --- atomstrom.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/atomstrom.py b/atomstrom.py index c752e2d..dec2940 100755 --- a/atomstrom.py +++ b/atomstrom.py @@ -10,6 +10,7 @@ import sys import urllib import hn import html2text +from optparse import OptionParser Base = declarative_base() @@ -246,8 +247,17 @@ def fetch_all_feeds(): print if __name__ == '__main__': - fetch_all_feeds() - mail_single_entries() - #mail_daily_digest() + parser = OptionParser() + parser.add_option("-f", "--fetch", action="store_true", dest="fetch", default=False, help="fetch all feeds") + parser.add_option("-s", "--single", action="store_true", dest="single", default=False, help="send single mails") + parser.add_option("-d", "--daily", action="store_true", dest="daily", default=False, help="send daily digest") + (options, args) = parser.parse_args() + + if options.fetch: + fetch_all_feeds() + if options.single: + mail_single_entries() + if options.daily: + mail_daily_digest() session.commit()