Commit f01b5073 authored by Samuel GAIST's avatar Samuel GAIST

[algorithms] Use raise_on_error decorator for commands

parent 758504e4
......@@ -28,20 +28,18 @@
import click
import logging
import os
import sys
import docopt
import simplejson as json
from . import common
from beat.cmdline.scripts.click_helper import AliasedGroup
from beat.core import algorithm
from beat.core.execution import DockerExecutor
from beat.core.dock import Host
from beat.core import hash
from beat.backend.python.database import Storage as DatabaseStorage
from beat.backend.python.algorithm import Storage as AlgorithmStorage
from . import common
from .decorators import raise_on_error
logger = logging.getLogger(__name__)
......@@ -298,6 +296,7 @@ def algorithms(ctx):
@click.option('--remote', help='Only acts on the remote copy of the algorithm',
is_flag=True)
@click.pass_context
@raise_on_error
def list(ctx, remote):
'''Lists all the algorithms available on the platform
......@@ -313,6 +312,7 @@ def list(ctx, remote):
@algorithms.command()
@click.argument('names', nargs=-1)
@click.pass_context
@raise_on_error
def path(ctx, names):
'''Displays local path of algorithm files
......@@ -325,6 +325,7 @@ def path(ctx, names):
@algorithms.command()
@click.argument('name', nargs=1)
@click.pass_context
@raise_on_error
def edit(ctx, name):
'''Edit local algorithm file
......@@ -339,6 +340,7 @@ def edit(ctx, name):
@algorithms.command()
@click.argument('name', nargs=-1)
@click.pass_context
@raise_on_error
def check(ctx, name):
'''Checks a local algorithm for validity
......@@ -354,6 +356,7 @@ def check(ctx, name):
@click.option('--force', help='Performs operation regardless of conflicts',
is_flag=True)
@click.pass_context
@raise_on_error
def pull(ctx, name, force):
'''Downloads the specified algorithms from the server
......@@ -373,6 +376,7 @@ def pull(ctx, name, force):
@click.option('--dry-run', help="Doesn't really perform the task, just "
"comments what would do", is_flag=True)
@click.pass_context
@raise_on_error
def push(ctx, name, force, dry_run):
'''Uploads algorithms to the server
......@@ -389,6 +393,7 @@ def push(ctx, name, force, dry_run):
@algorithms.command()
@click.argument('name', nargs=1)
@click.pass_context
@raise_on_error
def diff(ctx, name):
'''Shows changes between the local algorithm and the remote version
......@@ -403,6 +408,7 @@ def diff(ctx, name):
@algorithms.command()
@click.pass_context
@raise_on_error
def status(ctx):
'''Shows (editing) status for all available algorithms
......@@ -417,6 +423,7 @@ def status(ctx):
@algorithms.command()
@click.argument('name', nargs=-1)
@click.pass_context
@raise_on_error
def create(ctx, name):
'''Creates a new local algorithm
......@@ -430,6 +437,7 @@ def create(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
......@@ -444,6 +452,7 @@ def version(ctx, name):
@click.argument('src', nargs=1)
@click.argument('dst', nargs=1)
@click.pass_context
@raise_on_error
def fork(ctx, src, dst):
'''Forks a local algorithm
......@@ -459,6 +468,7 @@ def fork(ctx, src, dst):
@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)
......@@ -478,6 +488,7 @@ def rm(ctx, name, remote):
@click.option('--example', help='Display some example JSON instruction files',
is_flag=True)
@click.pass_context
@raise_on_error
def execute(ctx, instructions, example):
'''Execute an algorithm following instructions in a JSON file
......
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