| 6 | |
| 7 | |
| 8 | def _build_parser(): |
| 9 | config_list = '\n'.join(f' {c}' for c in sorted(opencc.CONFIGS)) or ' (none found)' |
| 10 | parser = argparse.ArgumentParser( |
| 11 | prog='opencc', |
| 12 | description='Open Chinese Convert (OpenCC) Command Line Tool', |
| 13 | epilog=f'Built-in configurations:\n{config_list}', |
| 14 | formatter_class=argparse.RawDescriptionHelpFormatter, |
| 15 | ) |
| 16 | parser.add_argument( |
| 17 | '-c', '--config', |
| 18 | default='s2t.json', |
| 19 | metavar='<file>', |
| 20 | help='Configuration file (default: s2t.json)', |
| 21 | ) |
| 22 | parser.add_argument( |
| 23 | '-i', '--input', |
| 24 | metavar='<file>', |
| 25 | help='Input file (default: stdin)', |
| 26 | ) |
| 27 | parser.add_argument( |
| 28 | '-o', '--output', |
| 29 | metavar='<file>', |
| 30 | help='Output file (default: stdout)', |
| 31 | ) |
| 32 | parser.add_argument( |
| 33 | '--resource-zip', |
| 34 | metavar='<file>', |
| 35 | help='Load config and dictionaries from a resource zip file', |
| 36 | ) |
| 37 | parser.add_argument( |
| 38 | '--include-tofu-risk-dictionaries', |
| 39 | action='store_true', |
| 40 | default=False, |
| 41 | help='Include dictionaries that may output tofu characters', |
| 42 | ) |
| 43 | parser.add_argument( |
| 44 | '-v', '--version', |
| 45 | action='version', |
| 46 | version=f'OpenCC {opencc.__version__}', |
| 47 | ) |
| 48 | return parser |
| 49 | |
| 50 | |
| 51 | def main(): |