feat: adds command line args for dipoles and dots

This commit is contained in:
Deepak Mallubhotla 2024-04-20 19:17:43 -05:00
parent c63d553c7b
commit b5a3f76745
Signed by: deepak
GPG Key ID: BEBAEBF28083E022
2 changed files with 18 additions and 8 deletions

View File

@ -5,3 +5,7 @@ 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.
## CLI
the json files for dots and dipoles have a specific format that ignores extraneous data but is sad about missing fields.

View File

@ -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")