diff --git a/corrlib/cli.py b/corrlib/cli.py index 59bdc78..b85aa4e 100644 --- a/corrlib/cli.py +++ b/corrlib/cli.py @@ -2,8 +2,9 @@ from typing import Optional import typer from corrlib import __app_name__, __version__ from .initialization import create -from .toml import import_toml -from .find import find_record +from .toml import import_toml, update_project +from .find import find_record, find_project, list_projects +from .tools import str2list app = typer.Typer() @@ -13,6 +14,44 @@ def _version_callback(value: bool) -> None: raise typer.Exit() +@app.command() +def update( + path: str = typer.Option( + str('./corrlib'), + "--dataset", + "-d", + ), + uuid: str = typer.Argument(), +) -> None: + """ + Update a project by it's UUID. + """ + update_project(path, uuid) + return + +@app.command() +def list( + path: str = typer.Option( + str('./corrlib'), + "--dataset", + "-d", + ), + entities: str = typer.Argument('ensembles'), +) -> None: + """ + List entities. (ensembles, projects) + """ + if entities in ['ensembles', 'Ensembles','ENSEMBLES']: + results = "List of ensembles" + elif entities == 'projects': + results = list_projects(path) + header = "UUID".ljust(37) + "| Names" + print(header) + for project in results: + print(project[0], "|", " | ".join(str2list(project[1]))) + return + + @app.command() def find( path: str = typer.Option( @@ -23,6 +62,9 @@ def find( ensemble: str = typer.Argument(), corr: str = typer.Argument(), ) -> None: + """ + Find a record in the backlog at hand. Through specifying it's ensemble and the measured correlator. + """ results = find_record(path, ensemble, corr) print(results)