Commit ba961e5d authored by Samuel GAIST's avatar Samuel GAIST

[commands] Factored all edit commands to use common function

parent f00169c6
......@@ -335,21 +335,7 @@ def algorithms(ctx):
algorithms.command(name="list")(commands.command("list"))
algorithms.command(name="path")(commands.command("path"))
@algorithms.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local algorithm file
Example:
$ beat algorithms edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "algorithm", name
)
algorithms.command(name="edit")(commands.command("edit"))
@algorithms.command()
......
......@@ -94,7 +94,21 @@ def path_impl(ctx, names):
)
CMD_TABLE = {"list": list_impl, "path": path_impl}
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit_impl(ctx, name):
"""Edit local asset file
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}
def command(name):
......
......@@ -659,21 +659,7 @@ def databases(ctx):
databases.command(name="list")(commands.command("list"))
databases.command(name="path")(commands.command("path"))
@databases.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local database file
Example:
$ beat databases edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "database", name
)
databases.command(name="edit")(commands.command("edit"))
@databases.command()
......
......@@ -142,21 +142,7 @@ def dataformats(ctx):
dataformats.command(name="list")(commands.command("list"))
dataformats.command(name="path")(commands.command("path"))
@dataformats.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local dataformat file
Example:
$ beat df edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "dataformat", name
)
dataformats.command(name="edit")(commands.command("edit"))
@dataformats.command()
......
......@@ -692,6 +692,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()
......@@ -741,21 +742,6 @@ def caches(ctx, name, list, delete, checksum):
return caches_impl(config, name, list, delete, checksum)
@experiments.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local experiment file
Example:
$ beat experiments edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "experiment", name
)
@experiments.command()
@click.argument("names", nargs=-1)
@click.pass_context
......
......@@ -175,21 +175,7 @@ def libraries(ctx):
libraries.command(name="list")(commands.command("list"))
libraries.command(name="path")(commands.command("path"))
@libraries.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local library file
Example:
$ beat libraries edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "library", name
)
libraries.command(name="edit")(commands.command("edit"))
@libraries.command()
......
......@@ -103,21 +103,7 @@ def plotterparameters(ctx):
plotterparameters.command(name="list")(commands.command("list"))
plotterparameters.command(name="path")(commands.command("path"))
@plotterparameters.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local plotterparameter file
Example:
$ beat plotterparameter edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "plotterparameter", name
)
plotterparameters.command(name="edit")(commands.command("edit"))
@plotterparameters.command()
......
......@@ -319,21 +319,7 @@ def plotters(ctx):
plotters.command(name="list")(commands.command("list"))
plotters.command(name="path")(commands.command("path"))
@plotters.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local plotter file
Example:
$ beat plotters edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "plotter", name
)
plotters.command(name="edit")(commands.command("edit"))
@plotters.command()
......
......@@ -60,21 +60,7 @@ def protocoltemplates(ctx):
protocoltemplates.command(name="list")(commands.command("list"))
protocoltemplates.command(name="path")(commands.command("path"))
@protocoltemplates.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local database file
Example:
$ beat databases edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "protocoltemplate", name
)
protocoltemplates.command(name="edit")(commands.command("edit"))
@protocoltemplates.command()
......
......@@ -53,21 +53,7 @@ def toolchains(ctx):
toolchains.command(name="list")(commands.command("list"))
toolchains.command(name="path")(commands.command("path"))
@toolchains.command()
@click.argument("name", nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
"""Edit local toolchain file
Example:
$ beat toolchains edit xxx
"""
return common.edit_local_file(
ctx.meta["config"].path, ctx.meta["config"].editor, "toolchain", name
)
toolchains.command(name="edit")(commands.command("edit"))
@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