83 lines
2.3 KiB
Python
83 lines
2.3 KiB
Python
import argparse
|
|
import os
|
|
|
|
import remote
|
|
|
|
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,
|
|
nargs='+', choices=remote.ARCHITECTURES, help='''\
|
|
list of architectures to sync
|
|
''')
|
|
sync.add_argument(f'-{SUBSYSTEMS[0]}', f'--{SUBSYSTEMS}', type=str,
|
|
nargs='+', choices=['msys', 'mingw'], help='''\
|
|
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,
|
|
choices=['7z', 'gz', 'xz', 'zst'], help='''\
|
|
compression applying to archive
|
|
''')
|
|
|
|
parser.set_defaults(
|
|
directory=os.curdir,
|
|
temporary='tmp',
|
|
threads=2,
|
|
|
|
action='info',
|
|
|
|
remote='https://repo.msys2.org',
|
|
architectures=['x86_64'],
|
|
subsystems=['msys', 'mingw'],
|
|
|
|
filesystem='fs',
|
|
compression='7z',
|
|
)
|
|
|
|
return vars(parser.parse_args())
|