MCPcopy Index your code
hub / github.com/archlinux/archinstall / ArchConfigHandler

Class ArchConfigHandler

archinstall/lib/args.py:470–802  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

468
469
470class ArchConfigHandler:
471 def __init__(self) -> None:
472 self._parser: ArgumentParser = self._define_arguments()
473 self._add_sub_parsers()
474
475 self._args: Arguments = self._parse_args()
476 config = self._parse_config()
477
478 try:
479 self._config = ArchConfig.from_config(config, self._args)
480 self._config.version = get_version()
481 except ValueError as err:
482 warn(str(err))
483 sys.exit(1)
484
485 @property
486 def config(self) -> ArchConfig:
487 return self._config
488
489 @property
490 def args(self) -> Arguments:
491 return self._args
492
493 def get_script(self) -> str:
494 if script := self.args.script:
495 return script
496
497 if script := self.config.script:
498 return script
499
500 return 'guided'
501
502 def print_help(self) -> None:
503 self._parser.print_help()
504
505 def _add_sub_parsers(self) -> None:
506 subparsers = self._parser.add_subparsers(dest='command', help='Available subcommands')
507 _ = subparsers.add_parser(SubCommand.SHARE_LOG.value, help='Upload log file to public server')
508
509 def _define_arguments(self) -> ArgumentParser:
510 parser = ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
511
512 parser.add_argument(
513 '-v',
514 '--version',
515 action='version',
516 default=False,
517 version='%(prog)s ' + get_version(),
518 )
519 parser.add_argument(
520 '--config',
521 type=Path,
522 nargs='?',
523 default=None,
524 help='JSON configuration file',
525 )
526 parser.add_argument(
527 '--config-url',

Callers 15

test_creds_roundtripFunction · 0.90
test_default_argsFunction · 0.90
test_config_file_parsingFunction · 0.90
runFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls