#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from BootLib import ogGrubInstallPartition

parser = argparse.ArgumentParser (add_help=False)
parser.add_argument ('disk')
parser.add_argument ('par')
parser.add_argument ('checkos', nargs='?', default='FALSE')
parser.add_argument ('kernelparam', nargs='?', default='')

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogGrubInstallPartition', 'ogGrubInstallPartition int_ndiskSecondStage int_partitionSecondStage bolean_Configure_2ndStage "param param"', ['ogGrubInstallPartition 1 1 FALSE', 'ogGrubInstallPartition 1 1 TRUE "nomodeset irqpoll pci=noacpi quiet splash"'])
    sys.exit (0)

args = parser.parse_args()

ret = ogGrubInstallPartition (args.disk, args.par, args.checkos, args.kernelparam)
if ret is not None:
    if   ret == True: sys.exit (0)
    elif ret == False: sys.exit (1)
    else: print (ret)
