so,mme more cli tools

This commit is contained in:
Justus Kuhlmann 2025-03-30 17:59:52 +00:00
parent 50362d0fed
commit 9521e5d4e9

View file

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