write basic cli for init and import
This commit is contained in:
parent
4538969c10
commit
daab486f7b
4 changed files with 73 additions and 1 deletions
|
@ -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.
|
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 .main import *
|
||||||
from .input import *
|
from .input import *
|
||||||
from .initialization import *
|
from .initialization import *
|
||||||
from .meas_io import *
|
from .meas_io import *
|
||||||
from .find import *
|
from .find import *
|
||||||
|
from .version import __version__
|
||||||
|
|
9
corrlib/__main__.py
Normal file
9
corrlib/__main__.py
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
from corrlib import cli, __app_name__
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
cli.app(prog_name=__app_name__)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
60
corrlib/cli.py
Normal file
60
corrlib/cli.py
Normal file
|
@ -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
|
1
corrlib/version.py
Normal file
1
corrlib/version.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
__version__ = "0.0.2"
|
Loading…
Add table
Add a link
Reference in a new issue