Commit 3c408ca9 authored by Samuel GAIST's avatar Samuel GAIST

[commands] Factored all check commands to use common function

parent ba961e5d
......@@ -336,19 +336,7 @@ def algorithms(ctx):
algorithms.command(name="list")(commands.command("list"))
algorithms.command(name="path")(commands.command("path"))
algorithms.command(name="edit")(commands.command("edit"))
@algorithms.command()
@click.argument("name", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, name):
"""Checks a local algorithm for validity
Example:
$ beat algorithms check xxx
"""
return common.check(ctx.meta["config"].path, "algorithm", name)
algorithms.command(name="check")(commands.command("check"))
@algorithms.command()
......
......@@ -89,6 +89,7 @@ def path_impl(ctx, names):
Example:
$ beat <asset_type> path xxx
"""
return common.display_local_path(
ctx.meta["config"].path, ctx.meta["asset_type"], names
)
......@@ -103,12 +104,31 @@ def edit_impl(ctx, name):
Example:
$ beat <asset_type> edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, ctx.meta["asset_type"], name
)
CMD_TABLE = {"list": list_impl, "path": path_impl, "edit": edit_impl}
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check_impl(ctx, names):
"""Checks a local asset for validity.
Example:
$ beat <asset_type> check xxx
"""
return common.check(ctx.meta["config"].path, ctx.meta["asset_type"], names)
CMD_TABLE = {
"list": list_impl,
"path": path_impl,
"edit": edit_impl,
"check": check_impl,
}
def command(name):
......
......@@ -660,21 +660,7 @@ def databases(ctx):
databases.command(name="list")(commands.command("list"))
databases.command(name="path")(commands.command("path"))
databases.command(name="edit")(commands.command("edit"))
@databases.command()
@click.argument("db_names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, db_names):
"""Checks a local database for validity.
$ beat databases check [<name>]...
<name>:
Database name formatted as "<database>/<version>"
"""
return common.check(ctx.meta["config"].path, "database", db_names)
databases.command(name="check")(commands.command("check"))
@databases.command()
......
......@@ -143,19 +143,7 @@ def dataformats(ctx):
dataformats.command(name="list")(commands.command("list"))
dataformats.command(name="path")(commands.command("path"))
dataformats.command(name="edit")(commands.command("edit"))
@dataformats.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local dataformat for validity
Example:
$ beat dataformats check xxx
"""
return common.check(ctx.meta["config"].path, "dataformat", names)
dataformats.command(name="check")(commands.command("check"))
@dataformats.command()
......
......@@ -693,6 +693,7 @@ def experiments(ctx):
experiments.command(name="list")(commands.command("list"))
experiments.command(name="path")(commands.command("path"))
experiments.command(name="edit")(commands.command("edit"))
experiments.command(name="check")(commands.command("check"))
@experiments.command()
......@@ -742,19 +743,6 @@ def caches(ctx, name, list, delete, checksum):
return caches_impl(config, name, list, delete, checksum)
@experiments.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local experiment for validity.
$ beat experiments check xxx
"""
config = ctx.meta.get("config")
return common.check(config.path, "experiment", names)
@experiments.command()
@click.argument("names", nargs=-1)
@click.option(
......
......@@ -176,19 +176,7 @@ def libraries(ctx):
libraries.command(name="list")(commands.command("list"))
libraries.command(name="path")(commands.command("path"))
libraries.command(name="edit")(commands.command("edit"))
@libraries.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local library for validity
Example:
$ beat libraries check xxx
"""
return common.check(ctx.meta["config"].path, "library", names)
libraries.command(name="check")(commands.command("check"))
@libraries.command()
......
......@@ -104,18 +104,7 @@ def plotterparameters(ctx):
plotterparameters.command(name="list")(commands.command("list"))
plotterparameters.command(name="path")(commands.command("path"))
plotterparameters.command(name="edit")(commands.command("edit"))
@plotterparameters.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local plotter for validity.
$ beat plotterparameters check xxx
"""
return common.check(ctx.meta["config"].path, "plotterparameter", names)
plotterparameters.command(name="check")(commands.command("check"))
@plotterparameters.command()
......
......@@ -320,18 +320,7 @@ def plotters(ctx):
plotters.command(name="list")(commands.command("list"))
plotters.command(name="path")(commands.command("path"))
plotters.command(name="edit")(commands.command("edit"))
@plotters.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local plotter for validity.
$ beat plotters check xxx
"""
return common.check(ctx.meta["config"].path, "plotter", names)
plotters.command(name="check")(commands.command("check"))
@plotters.command()
......
......@@ -61,21 +61,7 @@ def protocoltemplates(ctx):
protocoltemplates.command(name="list")(commands.command("list"))
protocoltemplates.command(name="path")(commands.command("path"))
protocoltemplates.command(name="edit")(commands.command("edit"))
@protocoltemplates.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local database for validity.
$ beat databases check [<name>]...
<name>:
Database name formatted as "<database>/<version>"
"""
return common.check(ctx.meta["config"].path, "protocoltemplate", names)
protocoltemplates.command(name="check")(commands.command("check"))
@protocoltemplates.command()
......
......@@ -54,18 +54,7 @@ def toolchains(ctx):
toolchains.command(name="list")(commands.command("list"))
toolchains.command(name="path")(commands.command("path"))
toolchains.command(name="edit")(commands.command("edit"))
@toolchains.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, names):
"""Checks a local toolchain for validity.
$ beat toolchains check xxx
"""
return common.check(ctx.meta["config"].path, "toolchain", names)
toolchains.command(name="check")(commands.command("check"))
@toolchains.command()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment