INNER CODE UNIT · Python
_add_argument
jayin92/Skyfall-GS · arguments/__init__.py:52
def _add_argument(self, group, attr_name: str, default_value: Any, fill_none: bool):
"""Add a single argument to the parser group."""
# Check if attribute should have shorthand (starts with underscore)
has_shorthand = attr_name.startswith("_")
clean_name = attr_name[1:] if has_shorthand else attr_name
value_type = type(default_value)
final_default = None if fill_none else default_value
# Build argument parameters
arg_names = [f"--{clean_name}"]
if has_shorthand:
arg_names.append(f"-{clean_name[0]}")
# Add argument based on type
if value_type == bool:
group.add_argument(*arg_names, default=final_default, action="store_true")
else: