addDescription( 'Outputs page text to stdout' ); $this->addOption( 'show-private', 'Show the text even if it\'s not available to the public' ); $this->addArg( 'title', 'Page title' ); } public function execute() { $titleText = $this->getArg( 0 ); $title = Title::newFromText( $titleText ); if ( !$title ) { $this->fatalError( "$titleText is not a valid title.\n" ); } $rev = Revision::newFromTitle( $title ); if ( !$rev ) { $titleText = $title->getPrefixedText(); $this->fatalError( "Page $titleText does not exist.\n" ); } $content = $rev->getContent( $this->hasOption( 'show-private' ) ? Revision::RAW : Revision::FOR_PUBLIC ); if ( $content === false ) { $titleText = $title->getPrefixedText(); $this->fatalError( "Couldn't extract the text from $titleText.\n" ); } $this->output( $content->serialize() ); } } $maintClass = GetTextMaint::class; require_once RUN_MAINTENANCE_IF_MAIN;