summaryrefslogtreecommitdiff
path: root/buildscripts/phing/classes/phing/input
diff options
context:
space:
mode:
Diffstat (limited to 'buildscripts/phing/classes/phing/input')
-rwxr-xr-xbuildscripts/phing/classes/phing/input/DefaultInputHandler.php85
-rwxr-xr-xbuildscripts/phing/classes/phing/input/InputHandler.php45
-rwxr-xr-xbuildscripts/phing/classes/phing/input/InputRequest.php107
-rwxr-xr-xbuildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php58
-rwxr-xr-xbuildscripts/phing/classes/phing/input/YesNoInputRequest.php47
5 files changed, 0 insertions, 342 deletions
diff --git a/buildscripts/phing/classes/phing/input/DefaultInputHandler.php b/buildscripts/phing/classes/phing/input/DefaultInputHandler.php
deleted file mode 100755
index 5e53c878..00000000
--- a/buildscripts/phing/classes/phing/input/DefaultInputHandler.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-
-/*
- * $Id: 5d3d4fb125da3344b5aafec31ba330969bdbdb42 $
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/input/InputHandler.php';
-include_once 'phing/system/io/ConsoleReader.php';
-
-/**
- * Prompts using print(); reads input from Console.
- *
- * @author Hans Lellelid <hans@xmpl.org> (Phing)
- * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
- * @version $Id$
- * @package phing.input
- */
-class DefaultInputHandler implements InputHandler {
-
- /**
- * Prompts and requests input. May loop until a valid input has
- * been entered.
- * @throws BuildException
- */
- public function handleInput(InputRequest $request) {
- $prompt = $this->getPrompt($request);
- $in = new ConsoleReader();
- do {
- print $prompt;
- try {
- $input = $in->readLine();
- if ($input === "" && ($request->getDefaultValue() !== null) ) {
- $input = $request->getDefaultValue();
- }
- $request->setInput($input);
- } catch (Exception $e) {
- throw new BuildException("Failed to read input from Console.", $e);
- }
- } while (!$request->isInputValid());
- }
-
- /**
- * Constructs user prompt from a request.
- *
- * <p>This implementation adds (choice1,choice2,choice3,...) to the
- * prompt for <code>MultipleChoiceInputRequest</code>s.</p>
- *
- * @param $request the request to construct the prompt for.
- * Must not be <code>null</code>.
- */
- protected function getPrompt(InputRequest $request) {
- $prompt = $request->getPrompt();
- $defaultValue = $request->getDefaultValue();
-
- if ($request instanceof YesNoInputRequest) {
- $choices = $request->getChoices();
- $defaultValue = $choices[(int) !$request->getDefaultValue()];
- $prompt .= '(' . implode('/', $request->getChoices()) .')';
- } elseif ($request instanceof MultipleChoiceInputRequest) { // (a,b,c,d)
- $prompt .= '(' . implode(',', $request->getChoices()) . ')';
- }
-
- if ($request->getDefaultValue() !== null) {
- $prompt .= ' ['.$defaultValue.']';
- }
- $pchar = $request->getPromptChar();
- return $prompt . ($pchar ? $pchar . ' ' : ' ');
- }
-}
diff --git a/buildscripts/phing/classes/phing/input/InputHandler.php b/buildscripts/phing/classes/phing/input/InputHandler.php
deleted file mode 100755
index 9a414fd4..00000000
--- a/buildscripts/phing/classes/phing/input/InputHandler.php
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/*
- * $Id: c7412bfab167852910c4dfe935769e4b0c7ec9fe $
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-/**
- * Plugin to Phing to handle requests for user input.
- *
- * @author Stefan Bodewig <stefan.bodewig@epost.de>
- * @version $Id$
- * @package phing.input
- */
-interface InputHandler {
-
- /**
- * Handle the request encapsulated in the argument.
- *
- * <p>Precondition: the request.getPrompt will return a non-null
- * value.</p>
- *
- * <p>Postcondition: request.getInput will return a non-null
- * value, request.isInputValid will return true.</p>
- * @return void
- * @throws BuildException
- */
- public function handleInput(InputRequest $request);
-
-}
diff --git a/buildscripts/phing/classes/phing/input/InputRequest.php b/buildscripts/phing/classes/phing/input/InputRequest.php
deleted file mode 100755
index 1d9e156d..00000000
--- a/buildscripts/phing/classes/phing/input/InputRequest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-
-/*
- * $Id: f74cb3768bf512aeb0156b8de3e3b65c824cd0dc $
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-/**
- * Encapsulates an input request.
- *
- * @author Hans Lellelid <hans@xmpl.org> (Phing)
- * @author Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
- * @version $Id$
- * @package phing.input
- */
-class InputRequest {
-
- protected $prompt;
- protected $input;
- protected $defaultValue;
- protected $promptChar;
-
- /**
- * @param string $prompt The prompt to show to the user. Must not be null.
- */
- public function __construct($prompt) {
- if ($prompt === null) {
- throw new BuildException("prompt must not be null");
- }
- $this->prompt = $prompt;
- }
-
- /**
- * Retrieves the prompt text.
- */
- public function getPrompt() {
- return $this->prompt;
- }
-
- /**
- * Sets the user provided input.
- */
- public function setInput($input) {
- $this->input = $input;
- }
-
- /**
- * Is the user input valid?
- */
- public function isInputValid() {
- return true;
- }
-
- /**
- * Retrieves the user input.
- */
- public function getInput() {
- return $this->input;
- }
-
- /**
- * Set the default value to use.
- * @param mixed $v
- */
- public function setDefaultValue($v) {
- $this->defaultValue = $v;
- }
-
- /**
- * Return the default value to use.
- * @return mixed
- */
- public function getDefaultValue() {
- return $this->defaultValue;
- }
-
- /**
- * Set the default value to use.
- * @param string $c
- */
- public function setPromptChar($c) {
- $this->promptChar = $c;
- }
-
- /**
- * Return the default value to use.
- * @return string
- */
- public function getPromptChar() {
- return $this->promptChar;
- }
-}
diff --git a/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php b/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php
deleted file mode 100755
index 24e93b58..00000000
--- a/buildscripts/phing/classes/phing/input/MultipleChoiceInputRequest.php
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-/*
- * $Id: 12fcf735b10cae890d51bce8d3aebb637d9b6928 $
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/input/InputRequest.php';
-
-/**
- * Encapsulates an input request.
- *
- * @author Stefan Bodewig <stefan.bodewig@epost.de>
- * @version $Id$
- * @package phing.input
- */
-class MultipleChoiceInputRequest extends InputRequest {
-
- protected $choices = array();
-
- /**
- * @param string $prompt The prompt to show to the user. Must not be null.
- * @param array $choices holds all input values that are allowed.
- * Must not be null.
- */
- public function __construct($prompt, $choices) {
- parent::__construct($prompt);
- $this->choices = $choices;
- }
-
- /**
- * @return The possible values.
- */
- public function getChoices() {
- return $this->choices;
- }
-
- /**
- * @return true if the input is one of the allowed values.
- */
- public function isInputValid() {
- return in_array($this->getInput(), $this->choices); // not strict (?)
- }
-}
diff --git a/buildscripts/phing/classes/phing/input/YesNoInputRequest.php b/buildscripts/phing/classes/phing/input/YesNoInputRequest.php
deleted file mode 100755
index 1a712327..00000000
--- a/buildscripts/phing/classes/phing/input/YesNoInputRequest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-/*
- * $Id: 659526fec1ed2e66d5b9308fba48924ea3dda494 $
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * This software consists of voluntary contributions made by many individuals
- * and is licensed under the LGPL. For more information please see
- * <http://phing.info>.
- */
-
-require_once 'phing/input/MultipleChoiceInputRequest.php';
-
-/**
- * Encapsulates an input request that returns a boolean (yes/no).
- *
- * @author Hans Lellelid <hans@xmpl.org>
- * @version $Id: 659526fec1ed2e66d5b9308fba48924ea3dda494 $
- * @package phing.input
- */
-class YesNoInputRequest extends MultipleChoiceInputRequest {
-
- /**
- * @return true if the input is one of the allowed values.
- */
- public function isInputValid() {
- return StringHelper::isBoolean($this->input);
- }
-
- /**
- * Converts input to boolean.
- * @return boolean
- */
- public function getInput() {
- return StringHelper::booleanValue($this->input);
- }
-}