#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from ImageLib import ogCreateImageSyntax

parser = argparse.ArgumentParser (add_help=False)
parser.add_argument ('dev')
parser.add_argument ('imgfile')
parser.add_argument ('tool', nargs='?', default='partclone')
parser.add_argument ('level', nargs='?', default='gzip')

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogCreateImageSyntax', 'ogCreateImageSyntax path_device path_imagefile [str_tool] [str_compressionlevel]', ['ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img partclone lzop', 'ogCreateImageSyntax /dev/sda1 /opt/opengnsys/images/prueba.img'])
    sys.exit (0)

args = parser.parse_args()

ret = ogCreateImageSyntax (args.dev, args.imgfile, args.tool, args.level)
if ret is not None:
    if   ret == True: sys.exit (0)
    elif ret == False: sys.exit (1)
    else: print (ret)
