Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 20
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
WikiTexVcCli
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
1#!/usr/bin/env php
2<?php
3/**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 *
19 * @ingroup Maintenance
20 */
21
22require_once __DIR__ . '/../../../maintenance/Maintenance.php';
23
24// phpcs:disable MediaWiki.Files.ClassMatchesFilename.NotMatch
25class WikiTexVcCli extends Maintenance {
26
27    public function __construct() {
28        parent::__construct();
29        $this->addDescription( "This script checks if the input is valid texvc." .
30            "For valid input, it returns a normalized texvc string, " .
31            "otherwise the error code and detail are shown." );
32        $this->addArg( 'input', 'The tex input to be checked', true );
33        $this->addOption( 'chem', 'Set for chem input', false, false );
34        $this->requireExtension( 'Math' );
35    }
36
37    /**
38     * @throws Exception
39     */
40    public function execute() {
41        $userInputTex = $this->getArg( 0 );
42        $texvc = new MediaWiki\Extension\Math\WikiTexVC\TexVC();
43        $options = [ 'usemhchem' => $this->getOption( 'chem' ) ];
44        $result = $texvc->check( $userInputTex, $options );
45        if ( $result['status'] !== '+' ) {
46            $this->error( $result['status'] . $result['details'] );
47        }
48        $this->output( $result['output'] );
49        $this->output( "\n" );
50    }
51}
52
53$maintClass = WikiTexVcCli::class;
54/** @noinspection PhpIncludeInspection */
55require_once RUN_MAINTENANCE_IF_MAIN;