Skip to content

Commit d5decc5

Browse files
committed
Use main() as script entrypoint
1 parent 76284b6 commit d5decc5

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

archinstall/main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ def run() -> int:
8383
arch_config_handler.print_help()
8484
return 0
8585

86-
if arch_config_handler.get_script() == 'list':
86+
script = arch_config_handler.get_script()
87+
88+
if script == 'list':
8789
print(_list_scripts())
8890
return 0
8991

@@ -119,11 +121,10 @@ def run() -> int:
119121
else:
120122
debug('Running from ISO (Live Mode)...')
121123

122-
script = arch_config_handler.get_script()
123-
124124
mod_name = f'archinstall.scripts.{script}'
125125
# by loading the module we'll automatically run the script
126-
importlib.import_module(mod_name)
126+
module = importlib.import_module(mod_name)
127+
module.main()
127128

128129
return 0
129130

archinstall/scripts/guided.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def perform_installation(
190190
pass
191191

192192

193-
def guided() -> None:
193+
def main() -> None:
194194
mirror_list_handler = MirrorListHandler(
195195
offline=arch_config_handler.args.offline,
196196
verbose=arch_config_handler.args.verbose,
@@ -213,7 +213,7 @@ def guided() -> None:
213213
aborted = True
214214

215215
if aborted:
216-
return guided()
216+
return main()
217217

218218
if arch_config_handler.config.disk_config:
219219
fs_handler = FilesystemHandler(arch_config_handler.config.disk_config)
@@ -227,4 +227,5 @@ def guided() -> None:
227227
)
228228

229229

230-
guided()
230+
if __name__ == '__main__':
231+
main()

archinstall/scripts/minimal.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def perform_installation(mountpoint: Path) -> None:
5858
info(' * devel (password: devel)')
5959

6060

61-
def _minimal() -> None:
61+
def main() -> None:
6262
disk_config = DiskLayoutConfigurationMenu(disk_layout_config=None).run()
6363
arch_config_handler.config.disk_config = disk_config
6464

@@ -76,7 +76,7 @@ def _minimal() -> None:
7676
aborted = True
7777

7878
if aborted:
79-
return _minimal()
79+
return main()
8080

8181
if arch_config_handler.config.disk_config:
8282
fs_handler = FilesystemHandler(arch_config_handler.config.disk_config)
@@ -85,4 +85,5 @@ def _minimal() -> None:
8585
perform_installation(arch_config_handler.args.mountpoint)
8686

8787

88-
_minimal()
88+
if __name__ == '__main__':
89+
main()

archinstall/scripts/only_hd.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def perform_installation(mountpoint: Path) -> None:
5454
debug(f'Disk states after installing:\n{disk_layouts()}')
5555

5656

57-
def _only_hd() -> None:
57+
def main() -> None:
5858
if not arch_config_handler.args.silent:
5959
ask_user_questions()
6060

@@ -72,7 +72,7 @@ def _only_hd() -> None:
7272
aborted = True
7373

7474
if aborted:
75-
return _only_hd()
75+
return main()
7676

7777
if arch_config_handler.config.disk_config:
7878
fs_handler = FilesystemHandler(arch_config_handler.config.disk_config)
@@ -81,4 +81,5 @@ def _only_hd() -> None:
8181
perform_installation(arch_config_handler.args.mountpoint)
8282

8383

84-
_only_hd()
84+
if __name__ == '__main__':
85+
main()

0 commit comments

Comments
 (0)