-
Notifications
You must be signed in to change notification settings - Fork 3
/
base.py
52 lines (39 loc) · 1.07 KB
/
base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import logging
import click
from flask.cli import FlaskGroup, with_appcontext
from flask import current_app
# commands
from NIPTool.server import create_app, configure_app
# Get version and doc decorator
from NIPTool import __version__
LOG_LEVELS = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
LOG = logging.getLogger(__name__)
@click.version_option(__version__)
@click.group(
cls=FlaskGroup,
create_app=create_app,
add_default_commands=True,
invoke_without_command=False,
add_version_option=False)
@click.option("-c", "--config", type=click.File(), help="Path to config yaml file")
@with_appcontext
def cli(config):
""" Main entry point """
if current_app.test:
return
configure_app(current_app, config)
pass
@cli.command()
def test():
"""Test server using CLI"""
click.echo("test")
pass
@cli.command()
@with_appcontext
def name():
"""Returns the app name, for testing purposes, mostly"""
click.echo(current_app.name)
return current_app.name
cli.add_command(test)
cli.add_command(name)