1<?php
2
3use dokuwiki\Extension\CLIPlugin;
4use dokuwiki\plugin\wordimport\docx\DocX;
5use splitbrain\phpcli\Options;
6
7/**
8 * DokuWiki Plugin wordimport (CLI Component)
9 *
10 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
11 * @author  Andreas Gohr <dokuwiki@cosmocode.de>
12 */
13class cli_plugin_wordimport extends CLIPlugin
14{
15    /** @inheritDoc */
16    protected function setup(Options $options)
17    {
18        $options->setHelp('Import Microsoft Word documents into DokuWiki');
19
20        // main arguments
21        $options->registerArgument('docx', 'The .docx Word file', 'true');
22        $options->registerArgument(
23            'page',
24            'The page ID to where the contents should be imported. Will be overwritten if exists.',
25            'true'
26        );
27    }
28
29    /** @inheritDoc */
30    protected function main(Options $options)
31    {
32        auth_setup(); // we need this for ACL checks
33        $this->loadConfig();
34
35        [$docx, $page] = $options->getArgs();
36        $doc = new DocX($docx, $this->conf);
37        $doc->import($page);
38    }
39}
40