Commit fa1c94fa authored by Flavio TARSETTI's avatar Flavio TARSETTI

[server_cli] added beat.cmdline verbosity helper and added epilog

parent a51e7af8
Pipeline #23013 canceled with stages
in 2 minutes and 25 seconds
......@@ -36,9 +36,17 @@ import click
import pkg_resources
from click_plugins import with_plugins
from beat.cmdline.click_helper import AliasedGroup
from beat.cmdline.decorators import verbosity_option
from beat.cmdline.decorators import raise_on_error
from beat.cmdline.config import Configuration
EPILOG = '''\b
Example:
$ beat editor serve
$ beat editor serve --dev
To run the development server add option --dev
'''
@with_plugins(pkg_resources.iter_entry_points('beat.editor.cli'))
@click.group(cls=AliasedGroup)
......@@ -47,9 +55,7 @@ def editor(ctx):
"""beat.editor commands webserver."""
pass
@editor.command()
@click.option('--verbose', '-v', help='Increases the output verbosity level. Using "-vv" allows the program to output informational messages as it goes along.',
is_flag=True)
@editor.command(epilog=EPILOG)
@click.option('--version', '-V', help='Show version', is_flag=True)
@click.option('--dev', help='Use the development version, which doesn\'t open a new web browser tab.',
is_flag=True)
......@@ -59,9 +65,10 @@ def editor(ctx):
type=click.STRING)
@click.option('--cache', '-c', help='Overrides the cache prefix. If not set, use the value from your RC file, otherwise defaults to `<prefix>/%(cache)s\'',
type=click.STRING)
@verbosity_option()
@click.pass_context
@raise_on_error
def serve(ctx, verbose, version, dev, debug, prefix, cache):
def serve(ctx, version, dev, debug, prefix, cache):
'''Run Flask server
To run the development server add option --dev
......@@ -69,7 +76,6 @@ def serve(ctx, verbose, version, dev, debug, prefix, cache):
$ beat editor serve --dev
'''
ctx.meta['verbose'] = verbose
ctx.meta['version'] = version
ctx.meta['dev'] = dev
ctx.meta['debug'] = debug
......@@ -86,7 +92,7 @@ def serve(ctx, verbose, version, dev, debug, prefix, cache):
# Check that we are in a BEAT working folder
from ..utils import setup_logger
logger = setup_logger('beat.editor', verbose)
logger = setup_logger('beat.editor', ctx.meta['verbosity'])
config = Configuration(ctx.meta)
logger.info('BEAT prefix set to `%s\'', config.path)
......
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