2012-01-16 13:14:15 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of Composer.
|
|
|
|
*
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Composer\IO;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The Input/Output helper interface.
|
|
|
|
*
|
|
|
|
* @author François Pluchino <francois.pluchino@opendisplay.com>
|
|
|
|
*/
|
2012-01-17 22:13:35 +00:00
|
|
|
interface IOInterface
|
2012-01-17 22:07:33 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Is this input means interactive?
|
|
|
|
*
|
|
|
|
* @return Boolean
|
|
|
|
*/
|
2012-01-17 09:29:54 +00:00
|
|
|
function isInteractive();
|
|
|
|
|
2012-04-01 02:32:00 +00:00
|
|
|
/**
|
|
|
|
* Is this input verbose?
|
|
|
|
*
|
|
|
|
* @return Boolean
|
|
|
|
*/
|
|
|
|
function isVerbose();
|
|
|
|
|
2012-04-26 12:54:34 +00:00
|
|
|
/**
|
|
|
|
* Is this output decorated?
|
|
|
|
*
|
|
|
|
* @return Boolean
|
|
|
|
*/
|
|
|
|
function isDecorated();
|
|
|
|
|
2012-01-16 13:14:15 +00:00
|
|
|
/**
|
2012-01-17 22:07:33 +00:00
|
|
|
* Writes a message to the output.
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
2012-01-17 22:07:33 +00:00
|
|
|
* @param string|array $messages The message as an array of lines or a single string
|
2012-01-16 13:14:15 +00:00
|
|
|
* @param Boolean $newline Whether to add a newline or not
|
|
|
|
*/
|
2012-01-17 22:07:33 +00:00
|
|
|
function write($messages, $newline = true);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-17 22:07:33 +00:00
|
|
|
* Overwrites a previous message to the output.
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
2012-01-17 22:07:33 +00:00
|
|
|
* @param string|array $messages The message as an array of lines or a single string
|
|
|
|
* @param Boolean $newline Whether to add a newline or not
|
2012-01-18 11:51:37 +00:00
|
|
|
* @param integer $size The size of line
|
2012-01-16 13:14:15 +00:00
|
|
|
*/
|
2012-01-18 11:51:37 +00:00
|
|
|
function overwrite($messages, $newline = true, $size = 80);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks a question to the user.
|
|
|
|
*
|
2012-05-22 10:07:08 +00:00
|
|
|
* @param string|array $question The question to ask
|
|
|
|
* @param string $default The default answer if none is given by the user
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
|
|
|
* @return string The user answer
|
|
|
|
*
|
|
|
|
* @throws \RuntimeException If there is no data to read in the input stream
|
|
|
|
*/
|
2012-01-17 09:29:54 +00:00
|
|
|
function ask($question, $default = null);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks a confirmation to the user.
|
|
|
|
*
|
|
|
|
* The question will be asked until the user answers by nothing, yes, or no.
|
|
|
|
*
|
2012-05-22 10:07:08 +00:00
|
|
|
* @param string|array $question The question to ask
|
|
|
|
* @param Boolean $default The default answer if the user enters nothing
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
|
|
|
* @return Boolean true if the user has confirmed, false otherwise
|
|
|
|
*/
|
2012-01-17 09:29:54 +00:00
|
|
|
function askConfirmation($question, $default = true);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks for a value and validates the response.
|
|
|
|
*
|
|
|
|
* The validator receives the data to validate. It must return the
|
|
|
|
* validated data when the data is valid and throw an exception
|
|
|
|
* otherwise.
|
|
|
|
*
|
2012-05-22 10:07:08 +00:00
|
|
|
* @param string|array $question The question to ask
|
|
|
|
* @param callback $validator A PHP callback
|
|
|
|
* @param integer $attempts Max number of times to ask before giving up (false by default, which means infinite)
|
|
|
|
* @param string $default The default answer if none is given by the user
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*
|
|
|
|
* @throws \Exception When any of the validators return an error
|
|
|
|
*/
|
2012-01-17 09:29:54 +00:00
|
|
|
function askAndValidate($question, $validator, $attempts = false, $default = null);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Asks a question to the user and hide the answer.
|
|
|
|
*
|
|
|
|
* @param string $question The question to ask
|
|
|
|
*
|
|
|
|
* @return string The answer
|
|
|
|
*/
|
2012-01-17 09:29:54 +00:00
|
|
|
function askAndHideAnswer($question);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-17 13:53:50 +00:00
|
|
|
* Get all authorization informations entered.
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
2012-01-17 13:53:50 +00:00
|
|
|
* @return array The map of authorization
|
2012-01-16 13:14:15 +00:00
|
|
|
*/
|
2012-01-17 13:53:50 +00:00
|
|
|
function getAuthorizations();
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-17 13:53:50 +00:00
|
|
|
* Verify if the repository has a authorization informations.
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
|
|
|
* @param string $repositoryName The unique name of repository
|
|
|
|
*
|
|
|
|
* @return boolean
|
|
|
|
*/
|
2012-01-17 13:53:50 +00:00
|
|
|
function hasAuthorization($repositoryName);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the username and password of repository.
|
|
|
|
*
|
|
|
|
* @param string $repositoryName The unique name of repository
|
|
|
|
*
|
|
|
|
* @return array The 'username' and 'password'
|
|
|
|
*/
|
2012-01-17 13:53:50 +00:00
|
|
|
function getAuthorization($repositoryName);
|
2012-01-16 13:14:15 +00:00
|
|
|
|
|
|
|
/**
|
2012-01-17 13:53:50 +00:00
|
|
|
* Set the authorization informations for the repository.
|
2012-01-16 13:14:15 +00:00
|
|
|
*
|
|
|
|
* @param string $repositoryName The unique name of repository
|
|
|
|
* @param string $username The username
|
|
|
|
* @param string $password The password
|
|
|
|
*/
|
2012-01-17 13:53:50 +00:00
|
|
|
function setAuthorization($repositoryName, $username, $password = null);
|
2012-01-16 13:14:15 +00:00
|
|
|
}
|