18require_once __DIR__ .
'/Maintenance.php';
28 parent::__construct();
30 $this->
addOption(
'show-private',
'Show the text even if it\'s not available to the public' );
31 $this->
addArg(
'title',
'Page title' );
32 $this->
addOption(
'revision',
'Revision ID',
false,
true );
36 $titleText = $this->
getArg( 0 );
37 $title = Title::newFromText( $titleText );
39 $this->
fatalError(
"$titleText is not a valid title.\n" );
42 if ( !$title->exists() ) {
43 $titleText = $title->getPrefixedText();
44 $this->
fatalError(
"Page $titleText does not exist.\n" );
47 $revId = (int)$this->
getOption(
'revision', $title->getLatestRevID() );
51 ->getRevisionByTitle( $title, $revId );
54 $titleText = $title->getPrefixedText();
55 $this->
fatalError(
"Could not load revision $revId of $titleText.\n" );
58 $audience = $this->
hasOption(
'show-private' ) ?
60 RevisionRecord::FOR_PUBLIC;
61 $content = $rev->getContent( SlotRecord::MAIN, $audience );
63 if ( $content ===
null ) {
64 $titleText = $title->getPrefixedText();
65 $this->
fatalError(
"Couldn't extract the text from $titleText.\n" );
67 $this->
output( $content->serialize() );
69 if ( stream_isatty( STDOUT ) ) {
79require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that outputs page text to stdout.
execute()
Do the actual work.
__construct()
Default constructor.
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.
output( $out, $channel=null)
Throw some output to the user.
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.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.