| 1 |
#!/usr/bin/env php |
| 2 |
<?php |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
use MediaWiki\Maintenance\Maintenance; |
| 23 |
|
| 24 |
require_once __DIR__ . '/../../../maintenance/Maintenance.php'; |
| 25 |
|
| 26 |
|
| 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 |
|
| 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 |
|
| 57 |
require_once RUN_MAINTENANCE_IF_MAIN; |