def _reconstruct_target_kind_args(args, kind_name): kind_options = {} for target_option, target_type in TargetKind.options_from_name(kind_name).items(): if target_type in INTERNAL_TO_NATIVE_TYPE: var_name = f"target_{kind_name.replace('-', '_')}_{target_option.replace('-', '_')}" option_value = getattr(args, var_name) if option_value is not None: kind_options[target_option] = getattr(args, var_name) return kind_options
def _generate_target_kind_args(parser, kind_name): target_group = parser.add_argument_group(f"target {kind_name}") for target_option, target_type in TargetKind.options_from_name(kind_name).items(): if target_type in INTERNAL_TO_NATIVE_TYPE: target_group.add_argument( f"--target-{kind_name}-{target_option}", type=INTERNAL_TO_NATIVE_TYPE[target_type], help=f"target {kind_name} {target_option}{INTERNAL_TO_HELP[target_type]}", )