Skip to content

Commit

Permalink
Merge pull request #21 from cbib/help-menu
Browse files Browse the repository at this point in the history
update(main): add help menu, using click library
  • Loading branch information
johaGL authored Jan 24, 2024
2 parents 2eac14a + f2e66fb commit 20bda79
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/dimet/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
import os, sys

import hydra

from dimet.method import Method
from omegaconf import DictConfig, OmegaConf

from dimet.data import Dataset

import click

logger = logging.getLogger(__name__)


Expand All @@ -31,5 +34,18 @@ def main_run_analysis(cfg: DictConfig) -> None:
method.run(cfg, dataset)


@click.command(context_settings=dict(
help_option_names=['-h', '--help']) # needed to recognize -h as well
)
@click.option('-cd', type=str, required=True,
help="Directory containing the general configuration "
"(see -cn)")
@click.option('-cn', type=str, required=True,
help="File name of the general configuration "
"(only one .yaml file name)")
def main_run_analysis__or_display_help(cd, cn) -> None:
main_run_analysis() # run: hydra handles further arguments validation


if __name__ == "__main__":
main_run_analysis()
main_run_analysis__or_display_help()

0 comments on commit 20bda79

Please sign in to comment.