Skip to content

Commit

Permalink
modify approach to handling help
Browse files Browse the repository at this point in the history
  • Loading branch information
pearsonca authored and TimothyWillard committed Dec 11, 2024
1 parent b5142d9 commit b34792d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@


# add some basic commands to the CLI
@cli.command(params=[config_files_argument] + list(config_file_options.values()))
@cli.command(
params=[config_files_argument] + list(config_file_options.values()),
context_settings=dict(help_option_names=["-h", "--help"]),
)
@click.pass_context
def patch(ctx: click.Context = mock_context, **kwargs) -> None:
"""Merge configuration files
Expand Down
4 changes: 3 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/shared_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ def _parse_option(param: click.Parameter, value: Any) -> Any:
config_src = []
if len(found_configs) != 1:
if not found_configs:
raise ValueError(f"No config files provided.")
click.echo("No configuration provided! See help for required usage:\n")
click.echo(ctx.get_help())
ctx.exit()
else:
error_dict = {k: kwargs[k] for k in found_configs}
raise ValueError(
Expand Down
4 changes: 3 additions & 1 deletion flepimop/gempyor_pkg/src/gempyor/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,9 @@ def simulate(


@cli.command(
name="simulate", params=[config_files_argument] + list(config_file_options.values())
name="simulate",
params=[config_files_argument] + list(config_file_options.values()),
context_settings=dict(help_option_names=["-h", "--help"]),
)
@pass_context
def _click_simulate(ctx: Context, **kwargs) -> int:
Expand Down

0 comments on commit b34792d

Please sign in to comment.