[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor refactoring of CLI part

2016-09-16 Thread Seb35 (Code Review)
Seb35 has submitted this change and it was merged.

Change subject: Minor refactoring of CLI part
..


Minor refactoring of CLI part

Code:
* Create an abstract class AbstractMediaWikiFarmScript containing 
general-purpose
  methods and a real class MediaWikiFarmScript directly used by 
'bin/mwscript.php';
  the abstract class will be useful for another script in development about 
handling
  Composer-installed extensions

Bugs:
* Scripts in composer.json was in wrong (old) directory 'scripts'

Change-Id: I50e475b249a74b976b226215e652ab6552742244
---
M bin/mwscript.php
M composer.json
M phpcs.xml
R src/AbstractMediaWikiFarmScript.php
A src/MediaWikiFarmScript.php
R tests/phpunit/MediaWikiFarmScriptTest.php
6 files changed, 240 insertions(+), 117 deletions(-)

Approvals:
  Seb35: Verified; Looks good to me, approved



diff --git a/bin/mwscript.php b/bin/mwscript.php
index c1952f3..0cc21ee 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -1,6 +1,6 @@
 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
@@ -14,7 +14,7 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . '/src/Script.php';
+require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarmScript.php';
 
 # Prepare environment
 $wgMediaWikiFarmScript = new MediaWikiFarmScript( $argc, $argv );
diff --git a/composer.json b/composer.json
index 8feeb8e..7eb1384 100644
--- a/composer.json
+++ b/composer.json
@@ -22,9 +22,14 @@
"mediawiki/mediawiki-codesniffer": "*"
},
"scripts": {
-   "validate-schema": "php ./scripts/validate-schema.php",
-   "phpdoc": "./vendor/bin/phpdoc -d src,scripts -e php,php.txt -t 
./docs/code",
-   "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor 
.",
-   "phpcs": "phpcs -p -s"
+   "validate-schema": "php ./bin/validate-schema.php",
+   "lint": "parallel-lint --exclude vendor .",
+   "phpcs": "phpcs -p -s",
+   "phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "test": [
+   "composer lint",
+   "composer phpcs",
+   "composer phpdoc"
+   ]
}
 }
diff --git a/phpcs.xml b/phpcs.xml
index c52652f..6224889 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -23,6 +23,11 @@



+   
+   
+   
+   
+   


tests/perfs/results
diff --git a/src/Script.php b/src/AbstractMediaWikiFarmScript.php
similarity index 61%
rename from src/Script.php
rename to src/AbstractMediaWikiFarmScript.php
index 17774c5..1c0e972 100644
--- a/src/Script.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -7,13 +7,17 @@
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
  */
 
+// @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/MediaWikiFarm.php';
+// @codeCoverageIgnoreEnd
+
 /**
  * This class contains the major part of the script utility, mainly in the 
main() method.
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
  */
-class MediaWikiFarmScript {
+abstract class AbstractMediaWikiFarmScript {
 
/** @var int Number of input arguments. */
public $argc = 0;
@@ -21,11 +25,14 @@
/** @var string[] Input arguments. */
public $argv = array();
 
+   /** @var string Short usage, displayed on request or error. */
+   public $shortUsage = '';
+
+   /** @var string Long usage, displayed on request. */
+   public $longUsage = '';
+
/** @var string Host name. */
public $host = '';
-
-   /** @var string Script name. */
-   public $script = '';
 
/** @var int Status. */
public $status = 0;
@@ -35,7 +42,7 @@
 *
 * @param int $argc Number of input arguments.
 * @param string[] $argv Input arguments.
-* @return MediaWikiFarmScript
+* @return AbstractMediaWikiFarmScript
 */
function __construct( $argc, $argv ) {
 
@@ -97,47 +104,26 @@
}
 
/**
-* Display help and return success or error.
+* Display help.
 *
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param bool $error Return an error code?
-* @return void
+* @param bool $long Show extended usage.
+* @return void.
 */
-   function usage( $error = true ) {
-
-   $fullPath = realpath( $this->argv[0] );
+   function usage( $long = false ) {
 
# Minimal help, be it an error or not
-   echo <

[MediaWiki-commits] [Gerrit] mediawiki...MediaWikiFarm[master]: Minor refactoring of CLI part

2016-09-16 Thread Seb35 (Code Review)
Seb35 has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/311196

Change subject: Minor refactoring of CLI part
..

Minor refactoring of CLI part

Code:
* Create an abstract class AbstractMediaWikiFarmScript containing 
general-purpose
  methods and a real class MediaWikiFarmScript directly used by 
'bin/mwscript.php';
  the abstract class will be useful for another script in development about 
handling
  Composer-installed extensions

Bugs:
* Scripts in composer.json was in wrong (old) directory 'scripts'

Change-Id: I50e475b249a74b976b226215e652ab6552742244
---
M bin/mwscript.php
M composer.json
M phpcs.xml
R src/AbstractMediaWikiFarmScript.php
A src/MediaWikiFarmScript.php
R tests/phpunit/MediaWikiFarmScriptTest.php
6 files changed, 240 insertions(+), 117 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MediaWikiFarm 
refs/changes/96/311196/1

diff --git a/bin/mwscript.php b/bin/mwscript.php
index c1952f3..0cc21ee 100644
--- a/bin/mwscript.php
+++ b/bin/mwscript.php
@@ -1,6 +1,6 @@
 
  * @license GPL-3.0+ GNU General Public License v3.0 ou version ultérieure
@@ -14,7 +14,7 @@
 }
 
 # Load classes
-require_once dirname( dirname( __FILE__ ) ) . '/src/Script.php';
+require_once dirname( dirname( __FILE__ ) ) . '/src/MediaWikiFarmScript.php';
 
 # Prepare environment
 $wgMediaWikiFarmScript = new MediaWikiFarmScript( $argc, $argv );
diff --git a/composer.json b/composer.json
index 8feeb8e..7eb1384 100644
--- a/composer.json
+++ b/composer.json
@@ -22,9 +22,14 @@
"mediawiki/mediawiki-codesniffer": "*"
},
"scripts": {
-   "validate-schema": "php ./scripts/validate-schema.php",
-   "phpdoc": "./vendor/bin/phpdoc -d src,scripts -e php,php.txt -t 
./docs/code",
-   "parallel-lint": "./vendor/bin/parallel-lint --exclude vendor 
.",
-   "phpcs": "phpcs -p -s"
+   "validate-schema": "php ./bin/validate-schema.php",
+   "lint": "parallel-lint --exclude vendor .",
+   "phpcs": "phpcs -p -s",
+   "phpdoc": "phpdoc -d bin,src -t ./docs/code",
+   "test": [
+   "composer lint",
+   "composer phpcs",
+   "composer phpdoc"
+   ]
}
 }
diff --git a/phpcs.xml b/phpcs.xml
index c52652f..6224889 100644
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -23,6 +23,11 @@



+   
+   
+   
+   
+   


tests/perfs/results
diff --git a/src/Script.php b/src/AbstractMediaWikiFarmScript.php
similarity index 61%
rename from src/Script.php
rename to src/AbstractMediaWikiFarmScript.php
index 17774c5..1c0e972 100644
--- a/src/Script.php
+++ b/src/AbstractMediaWikiFarmScript.php
@@ -7,13 +7,17 @@
  * @license AGPL-3.0+ GNU Affero General Public License v3.0 ou version 
ultérieure
  */
 
+// @codeCoverageIgnoreStart
+require_once dirname( __FILE__ ) . '/MediaWikiFarm.php';
+// @codeCoverageIgnoreEnd
+
 /**
  * This class contains the major part of the script utility, mainly in the 
main() method.
  * Using a class instead of a raw script it better for testability purposes 
and to use
  * less global variables (in fact none; the only global variable written are 
for
  * compatibility purposes, e.g. PHPUnit expects $_SERVER['argv']).
  */
-class MediaWikiFarmScript {
+abstract class AbstractMediaWikiFarmScript {
 
/** @var int Number of input arguments. */
public $argc = 0;
@@ -21,11 +25,14 @@
/** @var string[] Input arguments. */
public $argv = array();
 
+   /** @var string Short usage, displayed on request or error. */
+   public $shortUsage = '';
+
+   /** @var string Long usage, displayed on request. */
+   public $longUsage = '';
+
/** @var string Host name. */
public $host = '';
-
-   /** @var string Script name. */
-   public $script = '';
 
/** @var int Status. */
public $status = 0;
@@ -35,7 +42,7 @@
 *
 * @param int $argc Number of input arguments.
 * @param string[] $argv Input arguments.
-* @return MediaWikiFarmScript
+* @return AbstractMediaWikiFarmScript
 */
function __construct( $argc, $argv ) {
 
@@ -97,47 +104,26 @@
}
 
/**
-* Display help and return success or error.
+* Display help.
 *
-* @mediawikifarm-const
-* @mediawikifarm-idempotent
-*
-* @param bool $error Return an error code?
-* @return void
+* @param bool $long Show extended usage.
+* @return void.
 */
-   function usage( $error = true ) {
-
-   $fullPath = realpath( $this->argv[0] );
+   function usage( $long = false ) {
 
# Minimal help, be it an