Skip to content

Commit

Permalink
Update user permission check for --help (archlinux#2568)
Browse files Browse the repository at this point in the history
* Update user permission check for --help

* Fix code style

* Fix code style

* Fix docstring

* Fix newline

* Fix newline

* Fix argument error

* Fix formatting
  • Loading branch information
itstrueitstrueitsrealitsreal authored Jul 11, 2024
1 parent 50d2699 commit 0f1c8ab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions archinstall/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@
# For support reasons, we'll log the disk layout pre installation to match against post-installation layout
debug(f"Disk states before installing: {disk.disk_layouts()}")

if 'sphinx' not in sys.modules and os.getuid() != 0:
print(_("Archinstall requires root privileges to run. See --help for more."))
exit(1)

parser = ArgumentParser()


Expand Down Expand Up @@ -96,6 +92,16 @@ def define_arguments():
help="Skip the version check when running archinstall")


if 'sphinx' not in sys.modules:
if '--help' in sys.argv or '-h' in sys.argv:
define_arguments()
parser.print_help()
exit(0)
if os.getuid() != 0:
print(_("Archinstall requires root privileges to run. See --help for more."))
exit(1)


def parse_unspecified_argument_list(unknowns: list, multiple: bool = False, err: bool = False) -> dict:
"""We accept arguments not defined to the parser. (arguments "ad hoc").
Internally argparse return to us a list of words so we have to parse its contents, manually.
Expand Down

0 comments on commit 0f1c8ab

Please sign in to comment.