#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from FileLib import ogCalculateFullChecksum

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogCalculateFullChecksum', 'ogCalculateFullChecksum [ str_repo | int_ndisk int_npartition ] path_filepath', ['ogCalculateFullChecksum REPO ubuntu.img'])
    sys.exit (0)

parser = argparse.ArgumentParser (add_help=False)
if 3 == len (sys.argv):
    parser.add_argument ('container', nargs='?', default=None)
    parser.add_argument ('file', nargs='?', default=None)
elif 4 == len (sys.argv):
    parser.add_argument ('disk', nargs='?', default=None)
    parser.add_argument ('par', nargs='?', default=None)
    parser.add_argument ('file', nargs='?', default=None)

args = parser.parse_args()

if 3 == len (sys.argv):
    ret = ogCalculateFullChecksum (container=args.container, file=args.file)
elif 4 == len (sys.argv):
    ret = ogCalculateFullChecksum (container=f'{args.disk} {args.par}', file=args.file)

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