Page MenuHomeDevCentral

D1555.id3974.diff
No OneTemporary

D1555.id3974.diff

diff --git a/composer.json b/composer.json
--- a/composer.json
+++ b/composer.json
@@ -17,7 +17,8 @@
],
"require": {
"vlucas/phpdotenv": "dev-master",
- "nasqueron/saas-service": "^0.0.1"
+ "nasqueron/saas-service": "^0.0.1",
+ "keruald/commands": "^0.0.1"
},
"autoload": {
"psr-4": {
diff --git a/src/Utilities/Command.php b/src/Utilities/Command.php
deleted file mode 100644
--- a/src/Utilities/Command.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-namespace Nasqueron\SAAS\MediaWiki\Utilities;
-
-abstract class Command {
-
- public const EXIT_SUCCESS = 0;
- public const EXIT_FAILURE = 1;
-
- /**
- * @var int
- */
- protected $argc;
-
- /**
- * @var int
- */
- protected $argv;
-
- /**
- * @var \Nasqueron\SAAS\MediaWiki\Utilities\Display
- */
- protected $display;
-
- public function __construct (int $argc, array $argv, Display $display = null) {
- $this->argc = $argc;
- $this->argv = $argv;
-
- if ($display === null) {
- $display = new OutputDisplay();
- }
- $this->display = $display;
- }
-
- public static function run (int $argc, array $argv) : int {
- $command = new static($argc, $argv);
- return $command->main();
- }
-
- public function getCommandName () : string {
- return $this->argv[0];
- }
-
- ///
- /// Methods to implement
- ///
-
- public abstract function main () : int;
-
-}
diff --git a/src/Utilities/Display.php b/src/Utilities/Display.php
deleted file mode 100644
--- a/src/Utilities/Display.php
+++ /dev/null
@@ -1,10 +0,0 @@
-<?php
-
-namespace Nasqueron\SAAS\MediaWiki\Utilities;
-
-abstract class Display {
-
- abstract function out (string $message) : void;
- abstract function error (string $message) : void;
-
-}
diff --git a/src/Utilities/GetHost.php b/src/Utilities/GetHost.php
--- a/src/Utilities/GetHost.php
+++ b/src/Utilities/GetHost.php
@@ -6,18 +6,20 @@
use Nasqueron\SAAS\MediaWiki\Configuration\Settings;
use Nasqueron\SAAS\InstanceNotFoundException;
+use Keruald\Commands\Command;
+
class GetHost extends Command {
public const EXIT_HOST_NOT_FOUND = 2;
public function main () : int {
- if ($this->argc < 2) {
+ if ($this->getArgc() < 2) {
self::usage();
return 1;
}
try {
- $this->display->out($this->search($this->argv[1]));
+ $this->display->out($this->search($this->getArgv()[1]));
} catch (InstanceNotFoundException $exception) {
$this->display->error("Host not found.");
return self::EXIT_HOST_NOT_FOUND;
diff --git a/src/Utilities/OutputDisplay.php b/src/Utilities/OutputDisplay.php
deleted file mode 100644
--- a/src/Utilities/OutputDisplay.php
+++ /dev/null
@@ -1,15 +0,0 @@
-<?php
-
-namespace Nasqueron\SAAS\MediaWiki\Utilities;
-
-class OutputDisplay extends Display {
-
- public function out (string $message) : void {
- echo $message, "\n";
- }
-
- public function error (string $message) : void {
- fwrite(STDERR, $message . "\n");
- }
-
-}

File Metadata

Mime Type
text/plain
Expires
Mon, Nov 18, 15:47 (20 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2250795
Default Alt Text
D1555.id3974.diff (3 KB)

Event Timeline