def build_parser()

in obfuscator-cli/obfuscation_manager.py [0:0]


def build_parser() -> argparse.ArgumentParser:
    parser = argparse.ArgumentParser(
        description='Obfuscation script cli enter-point'
    )
    # -- top level sub-parser
    sub_parsers = parser.add_subparsers(dest='action', required=True,
                                        help='Available actions')
    obfuscate_parser = sub_parsers.add_parser(
        'obfuscate', help='Obfuscates an existing dump'
    )
    obfuscate_parser.add_argument(
        '--dump-directory', default='custodian_dump', type=Path,
        help='Path to the folder where custodian dump is sited '
             '(default: %(default)s)'
    )
    obfuscate_parser.add_argument(
        '--to', required=False, type=Path,
        help='Path the the patched data must be placed. If not specified, '
             'pathed data will override an existing dump'
    )
    obfuscate_parser.add_argument(
        '--keep-all-fields', action='store_true',
        help='If specified, all the fields will be kept. By default, '
             'only ID fields are kept'
    )
    obfuscate_parser.add_argument(
        '--dictionary-out', default='dictionary_out.json', type=Path,
        help='Path where obfuscated keys and their IDs will be places '
             '(default: %(default)s)'
    )
    obfuscate_parser.add_argument(
        '--dictionary', dest='dictionary_path', required=False, type=Path,
        help='Optional dict, in case you want to give some specific '
             'aliases for concrete names in resources. '
             'Path to file which contains JSON with key-value pairs, '
             'where key is real value of some attribute in resources '
             f'and value is a name you want to replace the real value with. '
             f'(default: %(default)s)'
    )
    deobfuscate_parser = sub_parsers.add_parser(
        'deobfuscate', help='De-obfuscates an existing dump'
    )
    deobfuscate_parser.add_argument(
        '--dump-directory', default='custodian_dump', type=Path,
        help='Path to the folder where the obfuscated custodian dump is '
             'sited. Can be also a path to concrete file '
             '(default: %(default)s)'
    )
    deobfuscate_parser.add_argument(
        '--to', required=False, type=Path,
        help='Path where the de-obfuscated data must be placed. '
             'If not specified, pathed data will override an existing dump'
    )
    deobfuscate_parser.add_argument(
        '--dictionary', required=True, nargs='+', type=Path,
        help='Path to a file where obfuscated keys and their IDs are'
    )
    return parser