IClick support

This commit is contained in:
Sergey Motornyuk 2019-12-13 16:44:52 +02:00
parent f67777c547
commit 1b6e26f5ce
3 changed files with 15 additions and 12 deletions

View File

@ -10,8 +10,6 @@ import ckan.model as model
from . import dbutil
from ckan.cli import error_shout, click_config_option
from ckan.cli.cli import CkanCommand
import ckan.plugins.toolkit as tk
log = logging.getLogger(__name__)
@ -22,14 +20,16 @@ RESOURCE_URL_REGEX = re.compile("/dataset/[a-z0-9-_]+/resource/([a-z0-9-_]+)")
DATASET_EDIT_REGEX = re.compile("/dataset/edit/([a-z0-9-_]+)")
@click.group(short_help=u"GoogleAnalytics commands")
@click.help_option(u"-h", u"--help")
@click_config_option
@click.pass_context
def googleanalytics(ctx, config, *args, **kwargs):
ctx.obj = CkanCommand(config)
def get_commands():
return [
googleanalytics
]
@click.group(short_help=u"GoogleAnalytics commands")
def googleanalytics():
pass
@googleanalytics.command()
def init():
"""Initialise the local stats database tables

View File

@ -7,10 +7,11 @@ import queue
import ckan.plugins as plugins
from ckanext.googleanalytics.views import ga
from ckanext.googleanalytics.cli import get_commands
class GAMixinPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IBlueprint)
plugins.implements(plugins.IClick)
analytics_queue = queue.Queue()
@ -18,3 +19,8 @@ class GAMixinPlugin(plugins.SingletonPlugin):
def get_blueprint(self):
return [ga]
# IClick
def get_commands(self):
return get_commands()

View File

@ -27,8 +27,5 @@ setup(
[paste.paster_command]
loadanalytics = ckanext.googleanalytics.commands:LoadAnalytics
initdb = ckanext.googleanalytics.commands:InitDB
[console_scripts]
ckanext-googleanalytics = ckanext.googleanalytics.cli:googleanalytics
""",
)