#!/usr/bin/python3

import sys
import os
import argparse

from gi.repository import Gio, GLib
sys.path.insert(0, os.path.join("/usr", "lib/warpinator/"))

# Secure mode enforcement
import prefs

parser = argparse.ArgumentParser(description="Send and Receive Files across the Network")
parser.add_argument("-d", "--debug", help="Print debugging information.",
                    action="store_true")
parser.add_argument("-a", "--autostart", help="Exit if (dconf) org.x.warpinator.preferences 'autostart' is false.",
                    action="store_true")
args = parser.parse_args()

if args.autostart:
    if not prefs.get_should_autostart():
        sys.exit(0)

del sys.argv[1:]

try:
    import warpinator
    sys.exit(warpinator.main(debug=args.debug))
except Exception as e:
    print(e)
    sys.exit(1)

