Skip to content

Commit

Permalink
Add test sample commands to CLI.
Browse files Browse the repository at this point in the history
  • Loading branch information
scossu committed Sep 11, 2024
1 parent 4491838 commit 00172a1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ the drop-down automatically. The value must be one of the keys found in
## Command-line interface

Various Scriptshifter commands can be accessed via the shell command `sscli`.
Note: at the moment only `sscli admin init-db` is available. More commands
will be made avaliable on an as-needed basis.
At the moment only a few essential admin and testing tools are available. More
commands can be made avaliable on an as-needed basis.

Help menu:

Expand Down
32 changes: 32 additions & 0 deletions sscli
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ __doc__ = """ Scriptshifter command line interface. """

import click

from glob import glob
from os import path

from scriptshifter import DB_PATH
from scriptshifter.tables import init_db as _init_db
from tests import test_sample


@click.group()
Expand All @@ -29,6 +33,34 @@ def init_db():
click.echo(f"Initialized Scriptshifter DB in {DB_PATH}")


@cli.group(name="test")
def test_grp():
""" Test operations. """
pass


@test_grp.command()
def list_samples():
""" List string sample sets that can be tested. """
path_ptn = path.join(
path.dirname(path.realpath(__file__)),
"tests", "data", "script_samples", "*.csv")
samples = [path.splitext(path.basename(fn))[0] for fn in glob(path_ptn)]

click.echo("\n".join(samples))


@test_grp.command()
@click.argument("lang")
def samples(lang):
"""
Test sample strings for language LANG.
LANG must match one of the names obtained with `test list-samples` command.
"""
return test_sample(lang)


@cli.group(name="trans")
def trans_grp():
""" Transliteration and transcription operations. """
Expand Down

0 comments on commit 00172a1

Please sign in to comment.