#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from PostConfLib import ogInstallRunonce

parser = argparse.ArgumentParser (add_help=False)
parser.add_argument ('disk')
parser.add_argument ('par')
parser.add_argument ('cmdfile')
parser.add_argument ('user')
parser.add_argument ('pwd')
parser.add_argument ('autologin')
parser.add_argument ('userauto', nargs='?', default=None)
parser.add_argument ('pwdauto', nargs='?', default=None)

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogInstallRunonce', 'ogInstallRunonce int_ndisk int_npartition str_filename str_adm_user str_adm_password bool_autologin [str_auto_user str_auto_password]', ['ogInstallRunonce 1 1 filename.cmd administrator passadmin 1 userauto passuserauto', 'ogInstallRunonce 1 1 filename.cmd administrator passadmin 0'])
    sys.exit (0)

args = parser.parse_args()

ret = ogInstallRunonce (args.disk, args.par, args.cmdfile, args.user, args.pwd, args.autologin, args.userauto, args.pwdauto)
if ret is not None:
    if   ret == True: sys.exit (0)
    elif ret == False: sys.exit (1)
    else: print (ret)
