diff --git a/README.md b/README.md index 6ab146f..4b1bd2b 100755 --- a/README.md +++ b/README.md @@ -4,4 +4,8 @@ Named as an oblique half-pun on both tantri as a form of generating, and tantri ## dev -Build with `just`, preferred over `do.sh` I think. \ No newline at end of file +Build with `just`, preferred over `do.sh` I think. + +## CLI + +the json files for dots and dipoles have a specific format that ignores extraneous data but is sad about missing fields. \ No newline at end of file diff --git a/tantri/cli/__init__.py b/tantri/cli/__init__.py index 74bc613..58bbbe6 100755 --- a/tantri/cli/__init__.py +++ b/tantri/cli/__init__.py @@ -8,27 +8,33 @@ LOG_PATTERN = "%(asctime)s | %(levelname)-7s | %(name)s | %(message)s" def _set_up_logging(filename): + handlers = [logging.StreamHandler()] + if filename is not None: + handlers.append(logging.FileHandler(filename)) # type: ignore idk what the typing issue is logging.basicConfig( level=logging.DEBUG, format=LOG_PATTERN, - handlers=[logging.StreamHandler(), logging.FileHandler(filename)], + handlers=handlers, ) logging.getLogger("pdme").setLevel(logging.INFO) logging.captureWarnings(True) @click.group() +@click.option("--log", help="Enable logging to stream only", is_flag=True, default=False) +@click.option("--log-file", help="A filename to use for logging (implies --log)") @click.version_option(tantri.get_version()) -@click.option("--log-file", help="A filename to use for logging") -def cli(log_file): - print("hi") - if log_file is not None: +def cli(log, log_file): + if log or (log_file is not None): # log file has been provided, let's log _set_up_logging(log_file) _logger.info("cli") @cli.command() -def hello(): +@click.option("--dipoles-file", default="dipoles.json", help="Filename containing json array of dipoles") +@click.option("--dots-file", default="dots.json", help="Filename containing json array of dots") +def hello(dipoles_file, dots_file): _logger.info("in hello") - print("in hello") + _logger.info(f"Received parameters [dipoles_file: {dipoles_file}] and [dots_file: {dots_file}]") + click.echo("in hello")