Arguments: <document id> [<page number>]

    Dump the content of the specified document.
    Beware, page numbers start from 1.
    See 'search' for the document ids.

    Replies with page content.
    Beware: This is the only command not replying in JSON format.

def cmd_dump(docid, page_nb=None):
    """
    Arguments: <document id> [<page number>]

    Dump the content of the specified document.
    Beware, page numbers start from 1.
    See 'search' for the document ids.

    Replies with page content.
    Beware: This is the only command not replying in JSON format.
    """
    dsearch = get_docsearch()
    doc = dsearch.get(docid)
    pages = doc.pages
    pages = [page for page in pages]
    if page_nb:
        page_nb = int(page_nb)
        pages = pages[page_nb - 1:page_nb]
    for page in pages:
        verbose("=== Page {} ===".format(page.page_nb + 1))
        _dump_page(page)