Commit 5ab3e5f5 authored by Samuel GAIST's avatar Samuel GAIST

[commands] Factored all version commands to use common function

parent 1baa7f51
......@@ -339,6 +339,7 @@ algorithms.command(name="edit")(commands.command("edit"))
algorithms.command(name="check")(commands.command("check"))
algorithms.command(name="status")(commands.command("status"))
algorithms.command(name="create")(commands.command("create"))
algorithms.command(name="version")(commands.command("version"))
@algorithms.command()
......@@ -410,19 +411,6 @@ def diff(ctx, name):
)
@algorithms.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing algorithm
Example:
$ beat algorithms version xxx
"""
return common.new_version(ctx.meta["config"].path, "algorithm", name)
@algorithms.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
......@@ -150,6 +150,19 @@ def create_impl(ctx, names):
return common.create(ctx.meta["config"].path, ctx.meta["asset_type"], names)
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version_impl(ctx, name):
"""Creates a new version of an existing asset
Example:
$ beat <asset_type> version xxx
"""
return common.new_version(ctx.meta["config"].path, ctx.meta["asset_type"], name)
CMD_TABLE = {
"list": list_impl,
"path": path_impl,
......@@ -157,6 +170,7 @@ CMD_TABLE = {
"check": check_impl,
"status": status_impl,
"create": create_impl,
"version": version_impl,
}
......
......@@ -663,6 +663,7 @@ databases.command(name="edit")(commands.command("edit"))
databases.command(name="check")(commands.command("check"))
databases.command(name="status")(commands.command("status"))
databases.command(name="create")(commands.command("create"))
databases.command(name="version")(commands.command("version"))
@databases.command()
......@@ -742,25 +743,6 @@ def diff(ctx, db_names):
)
@databases.command()
@click.argument("db_names", nargs=-1)
@click.pass_context
@raise_on_error
def version(ctx, db_names):
"""Creates a new version of an existing database.
$ beat databases version [<name>]...
<name>:
Database name formatted as "<database>/<version>"
"""
configuration = ctx.meta["config"]
if len(db_names) < 1:
raise click.ClickException("Requires at least one database name")
return common.new_version(configuration.path, "database", db_names[0])
@databases.command()
@click.argument("db_names", nargs=-1)
@click.option(
......
......@@ -146,6 +146,7 @@ dataformats.command(name="edit")(commands.command("edit"))
dataformats.command(name="check")(commands.command("check"))
dataformats.command(name="status")(commands.command("status"))
dataformats.command(name="create")(commands.command("create"))
dataformats.command(name="version")(commands.command("version"))
@dataformats.command()
......@@ -220,19 +221,6 @@ def diff(ctx, name):
)
@dataformats.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing dataformat
Example:
$ beat dataformats version xxx
"""
return common.new_version(ctx.meta["config"].path, "dataformat", name)
@dataformats.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
......@@ -179,6 +179,7 @@ libraries.command(name="edit")(commands.command("edit"))
libraries.command(name="check")(commands.command("check"))
libraries.command(name="status")(commands.command("status"))
libraries.command(name="create")(commands.command("create"))
libraries.command(name="version")(commands.command("version"))
@libraries.command()
......@@ -250,19 +251,6 @@ def diff(ctx, name):
)
@libraries.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing library
Example:
$ beat libraries version xxx
"""
return common.new_version(ctx.meta["config"].path, "library", name)
@libraries.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
......@@ -107,6 +107,7 @@ plotterparameters.command(name="edit")(commands.command("edit"))
plotterparameters.command(name="check")(commands.command("check"))
plotterparameters.command(name="status")(commands.command("status"))
plotterparameters.command(name="create")(commands.command("create"))
plotterparameters.command(name="version")(commands.command("version"))
@plotterparameters.command()
......@@ -126,18 +127,6 @@ def pull(ctx, names, force):
return pull_impl(webapi, ctx.meta["config"].path, name, force, 0, {})
@plotterparameters.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing plotter.
$ beat plotterparameters version xxx
"""
return common.new_version(ctx.meta["config"].path, "plotterparameter", name)
@plotterparameters.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
......@@ -323,6 +323,7 @@ plotters.command(name="edit")(commands.command("edit"))
plotters.command(name="check")(commands.command("check"))
plotters.command(name="status")(commands.command("status"))
plotters.command(name="create")(commands.command("create"))
plotters.command(name="version")(commands.command("version"))
@plotters.command()
......@@ -380,18 +381,6 @@ def plot(
)
@plotters.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing plotter.
$ beat plotters version xxx
"""
return common.new_version(ctx.meta["config"].path, "plotter", name)
@plotters.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
......@@ -37,10 +37,8 @@
import click
import logging
from . import common
from . import commands
from .decorators import raise_on_error
from .click_helper import AliasedGroup
......@@ -64,22 +62,4 @@ protocoltemplates.command(name="edit")(commands.command("edit"))
protocoltemplates.command(name="check")(commands.command("check"))
protocoltemplates.command(name="status")(commands.command("status"))
protocoltemplates.command(name="create")(commands.command("create"))
@protocoltemplates.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def version(ctx, names):
"""Creates a new version of an existing protocolt emplate.
$ beat databases version [<name>]...
<name>:
Protocol template name formatted as "<name>/<version>"
"""
configuration = ctx.meta["config"]
if len(names) < 1:
raise click.ClickException("Requires at least one database name")
return common.new_version(configuration.path, "protocoltemplate", names[0])
protocoltemplates.command(name="version")(commands.command("version"))
......@@ -57,6 +57,7 @@ toolchains.command(name="edit")(commands.command("edit"))
toolchains.command(name="check")(commands.command("check"))
toolchains.command(name="status")(commands.command("status"))
toolchains.command(name="create")(commands.command("create"))
toolchains.command(name="version")(commands.command("version"))
@toolchains.command()
......@@ -136,18 +137,6 @@ def diff(ctx, name):
)
@toolchains.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def version(ctx, name):
"""Creates a new version of an existing toolchain.
$ beat toolchains version xxx
"""
return common.new_version(ctx.meta["config"].path, "toolchain", name)
@toolchains.command()
@click.argument("src", nargs=1)
@click.argument("dst", nargs=1)
......
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