import sys
from uiplib.scheduler import scheduler

if __name__ == "__main__":
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    try:
        offline = False
        if len(sys.argv) > 1 and str(sys.argv[1]) == '--offline':
            print("You have choosen to run UIP in offline mode.")
            offline = True
        else:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(offline)
    except KeyboardInterrupt:
        sys.exit(0)

import sys, argparse, os, shutil
from uiplib.constants import CURR_DIR, PICS_FOLDER
from uiplib.scheduler import scheduler

if __name__ == "__main__":
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    parser = argparse.ArgumentParser()
    parser.add_argument("--offline", action="store_true",
                        help="Runs UIP in offline mode.")
    parser.add_argument("--flush", action="store_true",
                        help="Delete all downloaded wallpapers"
                             " and downloads new ones. "
                             "When combined with --offline,"
                             " deletes the wallpapers and exits.")
    args = parser.parse_args()
    try:
        if args.offline:
            print("You have choosen to run UIP in offline mode.")
        if args.flush:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(os.path.join(CURR_DIR, PICS_FOLDER))
                os.mkdir(os.path.join(CURR_DIR, PICS_FOLDER))
            except FileNotFoundError:
                pass
        if not args.offline:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(args.offline)
    except KeyboardInterrupt:
        sys.exit(0)

Add flag options for flush and offline modes
Add flag options for flush and offline modes

Fixes #65

- import sys
+ import sys, argparse, os, shutil
+ from uiplib.constants import CURR_DIR, PICS_FOLDER
  from uiplib.scheduler import scheduler
  
  if __name__ == "__main__":
      print("Hey this is UIP! you can use it to download"
            " images from reddit and also to schedule the setting of these"
            " images as your desktop wallpaper.")
+     parser = argparse.ArgumentParser()
+     parser.add_argument("--offline", action="store_true",
+                         help="Runs UIP in offline mode.")
+     parser.add_argument("--flush", action="store_true",
+                         help="Delete all downloaded wallpapers"
+                              " and downloads new ones. "
+                              "When combined with --offline,"
+                              " deletes the wallpapers and exits.")
+     args = parser.parse_args()
      try:
+         if args.offline:
-         offline = False
-         if len(sys.argv) > 1 and str(sys.argv[1]) == '--offline':
              print("You have choosen to run UIP in offline mode.")
-             offline = True
-         else:
+         if args.flush:
+             print("Deleting all downloaded wallpapers...")
+             try:
+                 shutil.rmtree(os.path.join(CURR_DIR, PICS_FOLDER))
+                 os.mkdir(os.path.join(CURR_DIR, PICS_FOLDER))
+             except FileNotFoundError:
+                 pass
+         if not args.offline:
              print("UIP will now connect to internet and download images"
                    " from reddit.")
-         scheduler(offline)
+         scheduler(args.offline)
      except KeyboardInterrupt:
          sys.exit(0)
  
Add flag options for flush and offline modes
## Code Before:
import sys
from uiplib.scheduler import scheduler

if __name__ == "__main__":
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    try:
        offline = False
        if len(sys.argv) > 1 and str(sys.argv[1]) == '--offline':
            print("You have choosen to run UIP in offline mode.")
            offline = True
        else:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(offline)
    except KeyboardInterrupt:
        sys.exit(0)

## Instruction:
Add flag options for flush and offline modes
## Code After:
import sys, argparse, os, shutil
from uiplib.constants import CURR_DIR, PICS_FOLDER
from uiplib.scheduler import scheduler

if __name__ == "__main__":
    print("Hey this is UIP! you can use it to download"
          " images from reddit and also to schedule the setting of these"
          " images as your desktop wallpaper.")
    parser = argparse.ArgumentParser()
    parser.add_argument("--offline", action="store_true",
                        help="Runs UIP in offline mode.")
    parser.add_argument("--flush", action="store_true",
                        help="Delete all downloaded wallpapers"
                             " and downloads new ones. "
                             "When combined with --offline,"
                             " deletes the wallpapers and exits.")
    args = parser.parse_args()
    try:
        if args.offline:
            print("You have choosen to run UIP in offline mode.")
        if args.flush:
            print("Deleting all downloaded wallpapers...")
            try:
                shutil.rmtree(os.path.join(CURR_DIR, PICS_FOLDER))
                os.mkdir(os.path.join(CURR_DIR, PICS_FOLDER))
            except FileNotFoundError:
                pass
        if not args.offline:
            print("UIP will now connect to internet and download images"
                  " from reddit.")
        scheduler(args.offline)
    except KeyboardInterrupt:
        sys.exit(0)
