32require_once __DIR__ .
'/Maintenance.php';
42 parent::__construct();
44 $this->
addOption(
'show-private',
'Show the text even if it\'s not available to the public' );
45 $this->
addArg(
'title',
'Page title' );
46 $this->
addOption(
'revision',
'Revision ID',
false,
true );
50 $titleText = $this->
getArg( 0 );
51 $title = Title::newFromText( $titleText );
53 $this->
fatalError(
"$titleText is not a valid title.\n" );
56 if ( !$title->exists() ) {
57 $titleText = $title->getPrefixedText();
58 $this->
fatalError(
"Page $titleText does not exist.\n" );
61 $revId = (int)$this->
getOption(
'revision', $title->getLatestRevID() );
65 ->getRevisionByTitle( $title, $revId );
68 $titleText = $title->getPrefixedText();
69 $this->
fatalError(
"Could not load revision $revId of $titleText.\n" );
72 $audience = $this->
hasOption(
'show-private' ) ?
74 RevisionRecord::FOR_PUBLIC;
75 $content = $rev->getContent( SlotRecord::MAIN, $audience );
77 if ( $content ===
null ) {
78 $titleText = $title->getPrefixedText();
79 $this->
fatalError(
"Couldn't extract the text from $titleText.\n" );
81 $this->
output( $content->serialize() );
83 if ( stream_isatty( STDOUT ) ) {
93require_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.