#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from ImageLib import ogUnlockImage

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogUnlockImage', 'ogUnlockImage [str_repo] path_image', ['ogUnlockImage /opt/opengnsys/images/aula1/win7.img', 'ogUnlockImage REPO /aula1/win7.img'])
    sys.exit (0)

parser = argparse.ArgumentParser (add_help=False)
if 2 == len (sys.argv):
    parser.add_argument ('file')
elif 3 == len (sys.argv):
    parser.add_argument ('container')
    parser.add_argument ('file')

args = parser.parse_args()

if 2 == len (sys.argv):
    ret = ogUnlockImage (imgfile=args.file)
elif 3 == len (sys.argv):
    ret = ogUnlockImage (container=args.container, imgfile=args.file)

if ret is not None:
    if   ret == True: sys.exit (0)
    elif ret == False: sys.exit (1)
    else: print (ret)
