Skip to content

Commit

Permalink
fix: args
Browse files Browse the repository at this point in the history
* fixing the args issues

* code automatically formatted

Signed-off-by: sentential[bot] <bot@sentential>

---------

Signed-off-by: sentential[bot] <bot@sentential>
Co-authored-by: sentential[bot] <bot@sentential>
  • Loading branch information
bkeane and sentential[bot] committed Jun 20, 2023
1 parent c86270f commit fce85da
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions sentential/cli/store.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
import typer
from typing import List
from rich import print
from typing import List, Tuple, Callable
from sentential.lib.store import Store
from sentential.lib.ontology import Ontology

store = typer.Typer()


@store.callback()
def namespace(ctx: typer.Context):
ctx.obj = getattr(Ontology(), str(ctx.command.name))
def _from_context(ctx: typer.Context) -> Tuple[Store, Callable]:
zero_arg, store, method, *n_arg = ctx.command_path.split(" ")
store = getattr(Ontology(), store)
method = getattr(store, method)
return (store, method)


@store.command()
def ls(ctx: typer.Context):
"""list store"""
print(getattr(ctx.obj, str(ctx.command.name))())
store, method = _from_context(ctx)
print(method())


@store.command()
def set(ctx: typer.Context, key: str, value: str):
"""set KEY VALUE in store"""
print(getattr(ctx.obj, str(ctx.command.name))(key, value))
store, method = _from_context(ctx)
print(method(key, value))


@store.command()
def rm(ctx: typer.Context, key: str):
"""delete KEY in store"""
print(getattr(ctx.obj, str(ctx.command.name))(key))
store, method = _from_context(ctx)
print(method(key))


@store.command()
def clear(ctx: typer.Context):
"""delete all in store"""
print(getattr(ctx.obj, str(ctx.command.name))())
store, method = _from_context(ctx)
print(method())

0 comments on commit fce85da

Please sign in to comment.