def init_argparse()

in python-threatexchange/threatexchange/cli/config_cmd.py [0:0]


    def init_argparse(cls, settings: CLISettings, ap: argparse.ArgumentParser) -> None:
        cfg_cls = cls._API_CLS.get_config_class()
        assert is_dataclass(cfg_cls)

        ap.add_argument("collab_name", help="the name of the collab")
        ap.set_defaults(api_name=cls._API_CLS.get_name())
        on_off = ap.add_mutually_exclusive_group()
        ap.add_argument(
            "--create",
            "-C",
            action="store_true",
            help="indicate you intend to create a config",
        )
        # This goofy syntax allows --enable, --enable=1, and enable=0 to disable
        on_off.add_argument(
            "--enable",
            nargs="?",
            type=int,
            const=1,
            choices=[0, 1],
            help="enable the config (default on create)",
        )
        on_off.add_argument(
            "--disable",
            dest="enable",
            action="store_const",
            const=0,
            help="disable the config",
        )
        ap.add_argument(
            "--only-signal-types",
            "-s",
            nargs="*",
            type=common.argparse_choices_pre_type(
                [s.get_name() for s in settings.get_all_signal_types()],
                settings.get_signal_type,
            ),
            metavar="NAME",
            help="limit to these signal types",
        )
        ap.add_argument(
            "--not-signal-types",
            "-S",
            nargs="*",
            type=common.argparse_choices_pre_type(
                [s.get_name() for s in settings.get_all_signal_types()],
                settings.get_signal_type,
            ),
            metavar="NAME",
            help="dont use these signal types",
        )
        ap.add_argument(
            "--only-owners",
            "-o",
            nargs="*",
            type=int,
            metavar="ID",
            help="only use signals from these owner ids",
        )
        ap.add_argument(
            "--not-owners",
            "-O",
            nargs="*",
            type=int,
            metavar="ID",
            help="dont use signals from these owner ids",
        )
        ap.add_argument(
            "--only-tags",
            "-t",
            nargs="*",
            metavar="TAG",
            help="use only signals with one of these tags",
        )
        ap.add_argument(
            "--not-tags",
            "-T",
            nargs="*",
            metavar="TAG",
            help="don't use signals with one of these tags",
        )
        ap.add_argument(
            "--json",
            "-J",
            dest="is_json",
            action="store_true",
            help="instead, interpret the argument as JSON and use that to edit the config",
        )

        for field in fields(cfg_cls):
            cls._add_argument(ap, field)