Skip to content

Commit

Permalink
Add configuration helper text.
Browse files Browse the repository at this point in the history
  • Loading branch information
YooSunYoung committed Dec 4, 2024
1 parent 89501b3 commit b18b0a8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/scicat_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,15 @@ def _parse_nested_input_args(input_args: argparse.Namespace) -> dict:
_SHORTENED_ARG_NAMES = MappingProxyType(
{
"config-file": "c",
"ingestion.dry-run": "d",
}
)

_HELP_TEXT = {
"config-file": "Path to the configuration file.",
"ingestion.dry-run": "Dry run mode. No data will be sent to SciCat.",
}


def _wrap_arg_names(name: str, *prefixes: str) -> tuple[str, ...]:
long_name = (".".join((*prefixes, name)) if prefixes else name).replace("_", "-")
Expand Down Expand Up @@ -90,7 +96,13 @@ def _add_arguments(dataclass_tp: type, prefixes: tuple[str, ...] = ()) -> None:
for name, tp in atomic_types.items():
arg_names = _wrap_arg_names(name, *prefixes)
required = any(arg_name in mandatory_args for arg_name in arg_names)
arg_adder = partial(group.add_argument, *arg_names, required=required)
long_name = arg_names[-1].replace("--", "")
arg_adder = partial(
group.add_argument,
*arg_names,
required=required,
help=_HELP_TEXT.get(long_name),
)
if tp is bool:
arg_adder(action="store_true")
elif tp in (int, float, str):
Expand Down

0 comments on commit b18b0a8

Please sign in to comment.