# Path: wikked/commands/base.py
# class WikkedCommand(object):
#     def __init__(self):
#         self.name = None
#         self.description = None
#         self.requires_wiki = True
# 
#     def setupParser(self, parser):
#         raise NotImplementedError()
# 
#     def run(self, ctx):
#         raise NotImplementedError()
# 
#     def _doRun(self, ctx):
#         if ctx.wiki is None and self.requires_wiki:
#             raise Exception("No wiki found here.")
#         result = self.run(ctx)
#         if result is None:
#             result = 0
#         return result
# 
# def register_command(cls):
#     command_classes.append(cls)
#     return cls


import logging
                import re
from wikked.commands.base import WikkedCommand, register_command
                nargs='+')

    def run(self, ctx):
        query = ' '.join(ctx.args.query)
        hits = ctx.wiki.index.search(query, highlight=False)
        if not hits:
            logger.info("No pages found.")
        else:
            for h in hits:
                logger.info("[[%s]]: %s" % (h.url, h.hl_text))


@register_command
class LinksFromCommand(WikkedCommand):
    def __init__(self):
        super(LinksFromCommand, self).__init__()
        self.name = 'linksfrom'
        self.description = "Gets the links going out from a given page."

    def setupParser(self, parser):
        parser.add_argument(
                'url',
                help="The page from which the links come from")

    def run(self, ctx):
        page = ctx.wiki.getPage(ctx.args.url)
        for l in page.links:
            logger.info(l)



# Path: wikked/commands/base.py
# class WikkedCommand(object):
#     def __init__(self):
#         self.name = None
#         self.description = None
#         self.requires_wiki = True
# 
#     def setupParser(self, parser):
#         raise NotImplementedError()
# 
#     def run(self, ctx):
#         raise NotImplementedError()
# 
#     def _doRun(self, ctx):
#         if ctx.wiki is None and self.requires_wiki:
#             raise Exception("No wiki found here.")
#         result = self.run(ctx)
#         if result is None:
#             result = 0
#         return result
# 
# def register_command(cls):
#     command_classes.append(cls)
#     return cls


# Path: wikked/commands/query.py
import logging
                import re
from wikked.commands.base import WikkedCommand, register_command

                nargs='+')

    def run(self, ctx):
        query = ' '.join(ctx.args.query)
        hits = ctx.wiki.index.search(query, highlight=False)
        if not hits:
            logger.info("No pages found.")
        else:
            for h in hits:
                logger.info("[[%s]]: %s" % (h.url, h.hl_text))


@register_command
class LinksFromCommand(WikkedCommand):
    def __init__(self):
        super(LinksFromCommand, self).__init__()
        self.name = 'linksfrom'
        self.description = "Gets the links going out from a given page."

    def setupParser(self, parser):
        parser.add_argument(
                'url',
                help="The page from which the links come from")

    def run(self, ctx):
        page = ctx.wiki.getPage(ctx.args.url)
        for l in page.links:
            logger.info(l)



@register_command