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 committed Dec 11, 2024
1 parent b5142d9 commit e6ced61
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion flepimop/gempyor_pkg/src/gempyor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@


# 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
3 changes: 2 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,8 @@ 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 e6ced61

Please sign in to comment.