16require_once __DIR__ .
'/Maintenance.php';
26 parent::__construct();
27 $this->
addArg(
'path',
'The file name to format',
false );
28 $this->
addOption(
'outfile',
'The output file name',
false,
true );
29 $this->
addOption(
'html',
'Use HTML output format. By default, wikitext is used.' );
33 if ( $this->
hasArg( 0 ) ) {
34 $fileName = $this->
getArg( 0 );
35 $inFile = fopen( $fileName,
'r' );
37 $this->
fatalError(
"Unable to open input file \"$fileName\"" );
44 $fileName = $this->
getOption(
'outfile' );
45 $outFile = fopen( $fileName,
'w' );
47 $this->
fatalError(
"Unable to open output file \"$fileName\"" );
53 $inText = stream_get_contents( $inFile );
54 $outText = InstallDocFormatter::format( $inText );
58 $opt = ParserOptions::newFromAnon();
59 $title = Title::newFromText(
'Text file' );
60 $out = $parser->parse( $outText, $title, $opt );
61 $outText =
"<html><body>\n" .
64 ->run( $out, $opt, [] )
65 ->getContentHolderText()
66 .
"\n</body></html>\n";
69 fwrite( $outFile, $outText );
75require_once RUN_MAINTENANCE_IF_MAIN;
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addArg( $arg, $description, $required=true, $multi=false)
Add some args that are needed.
getArg( $argId=0, $default=null)
Get an argument.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
hasArg( $argId=0)
Does a given argument exist?
getServiceContainer()
Returns the main service container.