diff --git a/corrlib/__init__.py b/corrlib/__init__.py index 55ecdaf..4c0f7de 100644 --- a/corrlib/__init__.py +++ b/corrlib/__init__.py @@ -13,9 +13,11 @@ it can be easily seen wehere the respective measurement came from and ho it may For now, we are interested in collecting primary IObservables only, as these are the most computationally expensive and time consuming to calculate. """ +__app_name__ = "corrlib" from .main import * from .input import * from .initialization import * from .meas_io import * -from .find import * \ No newline at end of file +from .find import * +from .version import __version__ diff --git a/corrlib/__main__.py b/corrlib/__main__.py new file mode 100644 index 0000000..ff94be6 --- /dev/null +++ b/corrlib/__main__.py @@ -0,0 +1,9 @@ +from corrlib import cli, __app_name__ + + +def main(): + cli.app(prog_name=__app_name__) + + +if __name__ == "__main__": + main() diff --git a/corrlib/cli.py b/corrlib/cli.py new file mode 100644 index 0000000..6dcd3ad --- /dev/null +++ b/corrlib/cli.py @@ -0,0 +1,60 @@ +from typing import Optional +import typer +from corrlib import __app_name__, __version__ +from .initialization import create +from .toml import import_toml +app = typer.Typer() + + +def _version_callback(value: bool) -> None: + if value: + typer.echo(f"{__app_name__} v{__version__}") + raise typer.Exit() + + +@app.command() +def importer( + path: str = typer.Option( + str('./corrlib'), + "--dataset", + "-d", + prompt="Which corrlib instance?" + ), + file: str = typer.Argument( + ), + copy_file: bool = typer.Option( + bool(True), + "--save", + "-s", + prompt="Copy config file?", + ), +) -> None: + import_toml(path, file, copy_file) + return + + +@app.command() +def init( + path: str = typer.Option( + str('./corrlib'), + "--dataset", + "-d", + prompt="Dataset location?", + ), +) -> None: + create(path) + return + + +@app.callback() +def main( + version: Optional[bool] = typer.Option( + None, + "--version", + "-v", + help="Show the application's version and exit.", + callback=_version_callback, + is_eager=True, + ) +) -> None: + return diff --git a/corrlib/version.py b/corrlib/version.py new file mode 100644 index 0000000..a0235ce --- /dev/null +++ b/corrlib/version.py @@ -0,0 +1 @@ +__version__ = "0.0.2" \ No newline at end of file