#!/usr/bin/python3

import sys
import argparse
from SystemLib import ogHelp
from UEFILib import ogNvramAddEntry

parser = argparse.ArgumentParser (add_help=False)
parser.add_argument ('bootlbl')
parser.add_argument ('bootldr')
parser.add_argument ('nvram_set', nargs='?', default=False)

if 2 == len (sys.argv) and 'help' == sys.argv[1]:
    #parser.print_help() sale en inglés aunque la locale indique otra cosa
    ogHelp ('ogNvramAddEntry', 'ogNvramAddEntry Str_label_entry Str_boot_loader [ Bool_add_bootorder ]', ['ogNvramAddEntry 1 2 TRUE', 'ogNvramAddEntry grub /EFI/grub/grubx64.efi TRUE', 'ogNvramAddEntry Windows /EFI/Microsoft/Boot/bootmgfw.efi'])
    sys.exit (0)

args = parser.parse_args()

ret = ogNvramAddEntry (args.bootlbl, args.bootldr, args.nvram_set)
if ret is not None:
    if   ret == True: sys.exit (0)
    elif ret == False: sys.exit (1)
    else: print (ret)
