update arg parser

This commit is contained in:
Julian Lobbes
2022-07-29 15:13:48 +02:00
parent 7904e4b0e7
commit 5665759667
2 changed files with 33 additions and 21 deletions

View File

@@ -4,6 +4,14 @@
As the name would suggest, it is a tool which builds a debian installation image which, if used to boot from, installs the *latest stable release* of Debian Linux to the machine without any user interaction required whatsoever. As the name would suggest, it is a tool which builds a debian installation image which, if used to boot from, installs the *latest stable release* of Debian Linux to the machine without any user interaction required whatsoever.
Configuration of the installed system is done by editing preseed files. Configuration of the installed system is done by editing preseed files.
** Usage
Obtaining a preseed example file:
#+begin_src shell
./udib.py get preseed-file
#+end_src
** Prerequisites ** Prerequisites
*** Target machine *** Target machine

View File

@@ -63,29 +63,10 @@ def _get_argument_parser():
""" """
# FIXME add a group hierarchy
# FIXME capture ISO filesystem name # FIXME capture ISO filesystem name
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
# create a group of mutually exclusive arguments
mutually_exclusive_group = parser.add_mutually_exclusive_group(
required=True)
mutually_exclusive_group.add_argument(
"--get-image",
help="Download the latest, unmodified Debian image and exit.",
action="store_true")
mutually_exclusive_group.add_argument(
"--get-preseed-file",
help="Download the latest Debian preseed example file and exit.",
action="store_true")
mutually_exclusive_group.add_argument(
"-p",
"--existing-preseed-file",
help="Path to the preseed configuration file to use.",
action="store")
# add all other arguments
parser.add_argument( parser.add_argument(
"-o", "-o",
"--output-file", "--output-file",
@@ -93,10 +74,31 @@ def _get_argument_parser():
type=str, type=str,
dest="path_to_output_file", dest="path_to_output_file",
action="store") action="store")
parser.add_argument(
subparsers = parser.add_subparsers(required=True)
parser_get = subparsers.add_parser("get")
parser_get.add_argument(
"WHAT",
type=str,
action="store",
help="What to retrieve (the latest installation image or the latest " \
"preseed file).",
choices=["image", "preseed-file"])
parser_insert = subparsers.add_parser("insert")
parser_insert.add_argument(
"FILES",
nargs="+",
type=str,
help="A list of files to insert into the root of an installation " \
"image.",
action="store")
parser_insert.add_argument(
"-i", "-i",
"--existing-image", "--existing-image",
help="Use an existing debian image file, do not download a new one.", help="Insert into an existing debian image file, instead of " \
"downloading a new one.",
type=str, type=str,
dest="path_to_existing_image", dest="path_to_existing_image",
action="store") action="store")
@@ -158,6 +160,8 @@ def main():
# FIXME capture ISO filesystem name # FIXME capture ISO filesystem name
iso_filesystem_name = "Debian UDIB" iso_filesystem_name = "Debian UDIB"
# FIXME adjust to new parser namespace
parser = _get_argument_parser() parser = _get_argument_parser()
args = parser.parse_args() args = parser.parse_args()