Debian Codegraph @

extensions/Math/maintenance/texvc.php

raw symbols SCIP
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
22 use MediaWiki\Maintenance\Maintenance;
23
24 require_once __DIR__ . '/../../../maintenance/Maintenance.php';
25
26 // phpcs:disable MediaWiki.Files.ClassMatchesFilename.NotMatch
27 class WikiTexVcCli extends Maintenance {
28
29 public function __construct() {
30 parent::__construct();
31 $this->addDescription( "This script checks if the input is valid texvc." .
32 "For valid input, it returns a normalized texvc string, " .
33 "otherwise the error code and detail are shown." );
34 $this->addArg( 'input', 'The tex input to be checked', true );
35 $this->addOption( 'chem', 'Set for chem input', false, false );
36 $this->requireExtension( 'Math' );
37 }
38
39 /**
40 * @throws Exception
41 */
42 public function execute() {
43 $userInputTex = $this->getArg( 0 );
44 $texvc = new MediaWiki\Extension\Math\WikiTexVC\TexVC();
45 $options = [ 'usemhchem' => $this->getOption( 'chem' ) ];
46 $result = $texvc->check( $userInputTex, $options );
47 if ( $result['status'] !== '+' ) {
48 $this->error( $result['status'] . $result['details'] );
49 }
50 $this->output( $result['output'] );
51 $this->output( "\n" );
52 }
53 }
54
55 $maintClass = WikiTexVcCli::class;
56 /** @noinspection PhpIncludeInspection */
57 require_once RUN_MAINTENANCE_IF_MAIN;