mrmp/arguments.py

84 lines
2.3 KiB
Python
Raw Normal View History

2021-10-09 10:26:08 +00:00
import argparse
import os
2021-10-10 01:52:31 +00:00
import msys
2021-10-09 10:26:08 +00:00
ACTION = 'action'
ARCHITECTURES = 'architectures'
COMPRESSION = 'compression'
DIRECTORY = 'directory'
FILESYSTEM = 'filesystem'
REMOTE = 'remote'
SUBSYSTEMS = 'subsystems'
TEMPORARY = 'temporary'
THREADS = 'threads'
VERBOSE = 'verbose'
class Formatter(argparse.RawTextHelpFormatter,
argparse.ArgumentDefaultsHelpFormatter):
pass
def parse():
parser = argparse.ArgumentParser(formatter_class=Formatter)
parser.add_argument(f'-{VERBOSE[0]}', f'--{VERBOSE}', type=bool, help='''\
verbose output
''')
parser.add_argument(f'-{DIRECTORY[0]}', f'--{DIRECTORY}', type=str,
help='''\
msys repository's directory
''')
parser.add_argument(f'--{TEMPORARY}', type=str, help='''\
msys repository's temporary directory
''')
parser.add_argument(f'-{THREADS[0]}', f'--{THREADS}', type=int, help='''\
number of threads to use
''')
parser.add_argument(f'{ACTION}', type=str, nargs='?',
choices=['build', 'check', 'info', 'sync'], help='''\
action to perform onto msys repository
''')
sync = parser.add_argument_group('sync')
sync.add_argument(f'-{REMOTE[0]}', f'--{REMOTE}', type=str, help='''\
msys remote repository's location
''')
sync.add_argument(f'-{ARCHITECTURES[0]}', f'--{ARCHITECTURES}', type=str,
2021-10-10 01:55:22 +00:00
nargs='+', choices=msys.ARCHITECTURES, help='''\
2021-10-09 10:26:08 +00:00
list of architectures to sync
''')
sync.add_argument(f'-{SUBSYSTEMS[0]}', f'--{SUBSYSTEMS}', type=str,
2021-10-10 01:52:31 +00:00
nargs='+', choices=msys.SUBSYSTEMS, help='''\
2021-10-09 10:26:08 +00:00
list of subsystems to sync
''')
build = parser.add_argument_group('build')
parser.add_argument(f'-{FILESYSTEM[0]}', f'--{FILESYSTEM}', type=str,
help='''\
directory containing modifications applying to filesystem
''')
build.add_argument(f'-{COMPRESSION[0]}', f'--{COMPRESSION}', type=str,
2021-10-10 01:52:31 +00:00
choices=['gz', 'xz', 'zst'], help='''\
2021-10-09 10:26:08 +00:00
compression applying to archive
''')
parser.set_defaults(
directory=os.curdir,
temporary='tmp',
threads=2,
action='info',
remote='https://repo.msys2.org',
architectures=['x86_64'],
2021-10-09 19:39:10 +00:00
subsystems=['msys', 'mingw'],
2021-10-09 10:26:08 +00:00
filesystem='fs',
2021-10-09 18:45:16 +00:00
compression='zst',
2021-10-09 10:26:08 +00:00
)
return vars(parser.parse_args())