#!/usr/bin/env python

import os
import gettext
import sys
import getopt
import Wammu

gettext.install('wammu', unicode=1)

def version():
    print _('Wammu - Windowed Gammu version %s') % Wammu.__version__

def usage():
    version()
    print _('Usage: wammu [OPTION...]')
    print
    print _('Options:')
    print _('-h/--help          ... show this help')
    print _('-v/--version       ... show program version')
    print _('-l/--local-locales ... use locales from current directory rather than system ones')
    print

try:
    opts, args = getopt.getopt(sys.argv[1:], 'hvl', ['help', 'version', 'local-locales'])
except getopt.GetoptError, val:
    usage()
    print _('Command line parsing failed with error:')
    print val
    sys.exit(2)

if len(args) != 0:
    usage()
    print _('Extra unrecognized parameters passed to program')
    sys.exit(3)

for o, a in opts:
    if o in ('-l', '--local-locales'):
        gettext.install('wammu','./locale/', unicode=1)
    if o in ('-h', '--help'):
        usage()
        sys.exit()
    if o in ('-v', '--version'):
        version()
        sys.exit()

# need to be imported after locales are initialised
import Wammu.App
Wammu.App.Run()
