Refactor script list (#4177)
This commit is contained in:
parent
bde544caca
commit
8ffc20b6c1
|
|
@ -6,6 +6,7 @@ import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from archinstall.lib.args import arch_config_handler
|
from archinstall.lib.args import arch_config_handler
|
||||||
from archinstall.lib.disk.utils import disk_layouts
|
from archinstall.lib.disk.utils import disk_layouts
|
||||||
|
|
@ -62,6 +63,16 @@ def _fetch_arch_db() -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def _list_scripts() -> str:
|
||||||
|
lines = ['The following are viable --script options:']
|
||||||
|
|
||||||
|
for file in (Path(__file__).parent / 'scripts').glob('*.py'):
|
||||||
|
if file.stem != '__init__':
|
||||||
|
lines.append(f' {file.stem}')
|
||||||
|
|
||||||
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
def run() -> int:
|
def run() -> int:
|
||||||
"""
|
"""
|
||||||
This can either be run as the compiled and installed application: python setup.py install
|
This can either be run as the compiled and installed application: python setup.py install
|
||||||
|
|
@ -72,6 +83,10 @@ def run() -> int:
|
||||||
arch_config_handler.print_help()
|
arch_config_handler.print_help()
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
if arch_config_handler.get_script() == 'list':
|
||||||
|
print(_list_scripts())
|
||||||
|
return 0
|
||||||
|
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
print(tr('Archinstall requires root privileges to run. See --help for more.'))
|
print(tr('Archinstall requires root privileges to run. See --help for more.'))
|
||||||
return 1
|
return 1
|
||||||
|
|
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
import glob
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
print('The following are viable --script options:')
|
|
||||||
|
|
||||||
for script in [Path(x) for x in glob.glob(f'{Path(__file__).parent}/*.py')]:
|
|
||||||
if script.stem in ['__init__', 'list']:
|
|
||||||
continue
|
|
||||||
|
|
||||||
print(f' {script.stem}')
|
|
||||||
Loading…
Reference in New Issue