Commit 270432b5 authored by Samuel GAIST's avatar Samuel GAIST

[commands] Factored all rm commands to use common function

Beware some of them are local only
parent bf4ac376
......@@ -341,6 +341,7 @@ algorithms.command(name="status")(commands.command("status"))
algorithms.command(name="create")(commands.command("create"))
algorithms.command(name="version")(commands.command("version"))
algorithms.command(name="fork")(commands.command("fork"))
algorithms.command(name="rm")(commands.command("rm"))
@algorithms.command()
......@@ -412,26 +413,6 @@ def diff(ctx, name):
)
@algorithms.command()
@click.argument("name", nargs=-1)
@click.option(
"--remote", help="Only acts on the remote copy of the algorithm", is_flag=True
)
@click.pass_context
@raise_on_error
def rm(ctx, name, remote):
"""Deletes a local algorithm (unless --remote is specified)
Example:
$ beat algorithms rm xxx
"""
if remote:
with common.make_webapi(ctx.meta["config"]) as webapi:
return common.delete_remote(webapi, "algorithm", name)
else:
return common.delete_local(ctx.meta["config"].path, "algorithm", name)
@algorithms.command()
@click.argument("instructions", nargs=1)
@click.option(
......
......@@ -177,6 +177,42 @@ def fork_impl(ctx, src, dst):
return common.fork(ctx.meta["config"].path, ctx.meta["asset_type"], src, dst)
@click.argument("name", nargs=-1)
@click.option(
"--remote", help="Only acts on the remote copy of the algorithm", is_flag=True
)
@click.pass_context
@raise_on_error
def rm_impl(ctx, name, remote):
"""Deletes a local asset (unless --remote is specified)
Example:
$ beat <asset_type> rm xxx
"""
config = ctx.meta["config"]
asset_type = ctx.meta["asset_type"]
if remote:
with common.make_webapi(config) as webapi:
return common.delete_remote(webapi, asset_type, name)
else:
return common.delete_local(config.path, asset_type, name)
@click.argument("name", nargs=-1)
@click.pass_context
@raise_on_error
def rm_local_impl(ctx, name, remote):
"""Deletes a local asset
Example:
$ beat <asset_type> rm xxx
"""
return common.delete_local(ctx.meta["config"], ctx.meta["asset_type"], name)
CMD_TABLE = {
"list": list_impl,
"path": path_impl,
......@@ -186,6 +222,8 @@ CMD_TABLE = {
"create": create_impl,
"version": version_impl,
"fork": fork_impl,
"rm": rm_impl,
"rm_local": rm_local_impl,
}
......
......@@ -664,6 +664,7 @@ 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(name="rm")(commands.command("rm_local"))
@databases.command()
......
......@@ -148,6 +148,7 @@ dataformats.command(name="status")(commands.command("status"))
dataformats.command(name="create")(commands.command("create"))
dataformats.command(name="version")(commands.command("version"))
dataformats.command(name="fork")(commands.command("fork"))
dataformats.command(name="rm")(commands.command("rm"))
@dataformats.command()
......@@ -220,23 +221,3 @@ def diff(ctx, name):
name,
["declaration", "description"],
)
@dataformats.command()
@click.argument("name", nargs=-1)
@click.option(
"--remote", help="Only acts on the remote copy of the dataformat", is_flag=True
)
@click.pass_context
@raise_on_error
def rm(ctx, name, remote):
"""Deletes a local dataformat (unless --remote is specified)
Example:
$ beat dataformats rm xxx
"""
if remote:
with common.make_webapi(ctx.meta["config"]) as webapi:
return common.delete_remote(webapi, "dataformat", name)
else:
return common.delete_local(ctx.meta["config"].path, "dataformat", name)
......@@ -696,6 +696,7 @@ experiments.command(name="edit")(commands.command("edit"))
experiments.command(name="check")(commands.command("check"))
experiments.command(name="status")(commands.command("status"))
experiments.command(name="fork")(commands.command("fork"))
experiments.command(name="rm")(commands.command("rm"))
@experiments.command()
......@@ -812,26 +813,6 @@ def diff(ctx, name):
)
@experiments.command()
@click.argument("names", nargs=-1)
@click.option(
"--remote", help="Only acts on the remote copy of the experiment", is_flag=True
)
@click.pass_context
@raise_on_error
def rm(ctx, names, remote):
"""Deletes a local experiment (unless --remote is specified).
$ beat experiments rm xxx
"""
config = ctx.meta.get("config")
if remote:
with common.make_webapi(config) as webapi:
return common.delete_remote(webapi, "experiment", names)
else:
return common.delete_local(config.path, "experiment", names)
@experiments.command()
@click.argument("names", nargs=-1)
@click.option(
......
......@@ -181,6 +181,7 @@ libraries.command(name="status")(commands.command("status"))
libraries.command(name="create")(commands.command("create"))
libraries.command(name="version")(commands.command("version"))
libraries.command(name="fork")(commands.command("fork"))
libraries.command(name="rm")(commands.command("rm"))
@libraries.command()
......@@ -250,23 +251,3 @@ def diff(ctx, name):
name,
["declaration", "code", "description"],
)
@libraries.command()
@click.argument("names", nargs=1)
@click.option(
"--remote", help="Only acts on the remote copy of the library", is_flag=True
)
@click.pass_context
@raise_on_error
def rm(ctx, names, remote):
"""Deletes a local library (unless --remote is specified)
Example:
$ beat libraries rm xxx
"""
if remote:
with common.make_webapi(ctx.meta["config"]) as webapi:
return common.delete_remote(webapi, "library", names)
else:
return common.delete_local(ctx.meta["config"].path, "library", names)
......@@ -109,6 +109,7 @@ plotterparameters.command(name="status")(commands.command("status"))
plotterparameters.command(name="create")(commands.command("create"))
plotterparameters.command(name="version")(commands.command("version"))
plotterparameters.command(name="fork")(commands.command("fork"))
plotterparameters.command(name="rm")(commands.command("rm_local"))
@plotterparameters.command()
......@@ -126,15 +127,3 @@ def pull(ctx, names, force):
if name is None:
return 1 # error
return pull_impl(webapi, ctx.meta["config"].path, name, force, 0, {})
@plotterparameters.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def rm(ctx, names):
"""Deletes a local plotter.
$ beat plotterparameters rm xxx
"""
return common.delete_local(ctx.meta["config"].path, "plotterparameter", names)
......@@ -325,6 +325,7 @@ plotters.command(name="status")(commands.command("status"))
plotters.command(name="create")(commands.command("create"))
plotters.command(name="version")(commands.command("version"))
plotters.command(name="fork")(commands.command("fork"))
plotters.command(name="rm")(commands.command("rm_local"))
@plotters.command()
......@@ -380,15 +381,3 @@ def plot(
0,
{},
)
@plotters.command()
@click.argument("names", nargs=-1)
@click.pass_context
@raise_on_error
def rm(ctx, names):
"""Deletes a local plotter.
$ beat plotters rm xxx
"""
return common.delete_local(ctx.meta["config"].path, "plotter", names)
......@@ -64,3 +64,4 @@ protocoltemplates.command(name="status")(commands.command("status"))
protocoltemplates.command(name="create")(commands.command("create"))
protocoltemplates.command(name="version")(commands.command("version"))
protocoltemplates.command(name="fork")(commands.command("fork"))
protocoltemplates.command(name="rm")(commands.command("rm_local"))
......@@ -59,6 +59,7 @@ toolchains.command(name="status")(commands.command("status"))
toolchains.command(name="create")(commands.command("create"))
toolchains.command(name="version")(commands.command("version"))
toolchains.command(name="fork")(commands.command("fork"))
toolchains.command(name="rm")(commands.command("rm"))
@toolchains.command()
......@@ -138,23 +139,6 @@ def diff(ctx, name):
)
@toolchains.command()
@click.argument("names", nargs=-1)
@click.option("--remote", help="Only acts on the remote copy.", is_flag=True)
@click.pass_context
@raise_on_error
def rm(ctx, names, remote):
"""Deletes a local toolchain (unless --remote is specified).
$ beat toolchains rm xxx
"""
if remote:
with common.make_webapi(ctx.meta["config"]) as webapi:
return common.delete_remote(webapi, "toolchain", names)
else:
return common.delete_local(ctx.meta["config"].path, "toolchain", names)
@toolchains.command()
@click.argument("names", nargs=-1)
@click.option(
......
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