本文整理汇总了PHP中Terminus::prompt方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::prompt方法的具体用法?PHP Terminus::prompt怎么用?PHP Terminus::prompt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus
的用法示例。
在下文中一共展示了Terminus::prompt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* Log in as a user
*
* ## OPTIONS
* [<email>]
* : Email address to log in as.
*
* [--password=<value>]
* : Log in non-interactively with this password. Useful for automation.
* [--debug]
* : dump call information when logging in.
*/
public function login($args, $assoc_args)
{
if (empty($args)) {
$email = Terminus::prompt("Your email address?", NULL);
} else {
$email = $args[0];
}
if (\Terminus\Utils\is_valid_email($email)) {
if (!isset($assoc_args['password'])) {
exec("stty -echo");
$password = Terminus::prompt("Your dashboard password (input will not be shown)");
exec("stty echo");
Terminus::line();
} else {
$password = $assoc_args['password'];
}
Terminus::line("Logging in as {$email}");
$data = $this->doLogin($email, $password);
if ($data != FALSE) {
if (array_key_exists("debug", $assoc_args)) {
$this->_debug(get_defined_vars());
}
Terminus::launch_self("art", array("fist"));
} else {
Terminus::error("Login Failed!");
}
} else {
Terminus::error("Error: invalid email address");
}
}
示例2: login
/**
* Log in as a user
*
* ## OPTIONS
* [<email>]
* : Email address to log in as.
*
* [--password=<value>]
* : Log in non-interactively with this password. Useful for automation.
*
* [--machine-token=<value>]
* : Authenticate using an Auth0 token
*
* [--debug]
* : dump call information when logging in.
*/
public function login($args, $assoc_args)
{
// Try to login using a machine token, if provided.
if (isset($assoc_args['machine-token']) || empty($args) && isset($_SERVER['TERMINUS_MACHINE_TOKEN'])) {
$token = $_SERVER['TERMINUS_MACHINE_TOKEN'];
if (isset($assoc_args['machine-token'])) {
$token = $assoc_args['machine-token'];
}
$this->auth->logInViaMachineToken($token);
} else {
// Otherwise, do a normal email/password-based login.
if (empty($args)) {
if (isset($_SERVER['TERMINUS_USER'])) {
$email = $_SERVER['TERMINUS_USER'];
} else {
$email = Terminus::prompt('Your email address?', null);
}
} else {
$email = $args[0];
}
if (isset($assoc_args['password'])) {
$password = $assoc_args['password'];
} else {
$password = Terminus::promptSecret('Your dashboard password (input will not be shown)');
}
$this->auth->logInViaUsernameAndPassword($email, $password);
}
$this->log()->debug(get_defined_vars());
Terminus::launchSelf('art', array('fist'));
}
示例3: login
/**
* Log in as a user
*
* ## OPTIONS
* [<email>]
* : Email address to log in as.
*
* [--password=<value>]
* : Log in non-interactively with this password. Useful for automation.
* [--session=<value>]
* : Authenticate using an existing session token
* [--debug]
* : dump call information when logging in.
*/
public function login($args, $assoc_args)
{
# First try to login using a session token if provided
if (isset($assoc_args['session'])) {
Terminus::line("Validating session token");
$data = $this->doLoginFromSessionToken($assoc_args['session']);
if ($data != FALSE) {
if (array_key_exists("debug", $assoc_args)) {
$this->_debug(get_defined_vars());
}
Terminus::line("Logged in as " . $data['email']);
Terminus::launch_self("art", array("fist"));
} else {
Terminus::error("Login Failed!");
}
return;
}
# Otherwise do a normal email/password-based login
if (empty($args)) {
if (isset($_SERVER['TERMINUS_USER'])) {
$email = $_SERVER['TERMINUS_USER'];
} else {
$email = Terminus::prompt("Your email address?", NULL);
}
} else {
$email = $args[0];
}
if (\Terminus\Utils\is_valid_email($email)) {
if (!isset($assoc_args['password'])) {
exec("stty -echo");
$password = Terminus::prompt("Your dashboard password (input will not be shown)");
exec("stty echo");
Terminus::line();
} else {
$password = $assoc_args['password'];
}
Terminus::line("Logging in as {$email}");
$data = $this->doLogin($email, $password);
if ($data != FALSE) {
if (array_key_exists("debug", $assoc_args)) {
$this->_debug(get_defined_vars());
}
Terminus::launch_self("art", array("fist"));
} else {
Terminus::error("Login Failed!");
}
} else {
Terminus::error("Error: invalid email address");
}
}
示例4: login
/**
* Log in as a user
*
* ## OPTIONS
* [<email>]
* : Email address to log in as.
*
* [--password=<value>]
* : Log in non-interactively with this password. Useful for automation.
* [--session=<value>]
* : Authenticate using an existing session token
* [--debug]
* : dump call information when logging in.
*/
public function login($args, $assoc_args)
{
# First try to login using a session token if provided
if (isset($assoc_args['session'])) {
$this->log()->info("Validating session token");
$data = $this->doLoginFromSessionToken($assoc_args['session']);
if ($data != FALSE) {
if (array_key_exists("debug", $assoc_args)) {
$this->_debug(get_defined_vars());
}
$this->log()->info("Logged in as " . $data['email']);
Terminus::launchSelf("art", array("fist"));
} else {
$this->failure('Login failed!');
}
return;
}
# Otherwise do a normal email/password-based login
if (empty($args)) {
if (isset($_SERVER['TERMINUS_USER'])) {
$email = $_SERVER['TERMINUS_USER'];
} else {
$email = Terminus::prompt("Your email address?", NULL);
}
} else {
$email = $args[0];
}
if (Utils\isValidEmail($email)) {
if (!isset($assoc_args['password'])) {
$password = Terminus::promptSecret('Your dashboard password (input will not be shown)');
} else {
$password = $assoc_args['password'];
}
$this->log()->info("Logging in as {$email}");
$data = $this->doLogin($email, $password);
if ($data != FALSE) {
if (array_key_exists("debug", $assoc_args)) {
$this->_debug(get_defined_vars());
}
Terminus::launchSelf("art", array("fist"));
} else {
$this->failure('Login Failed!');
}
} else {
$this->failure('Invalid email address');
}
}
示例5: string
/**
* Returns $args[key] if exists, then STDIN, then $default
*
* @param [array] $args Args already input
* @param [string] $key Key for searched-for argument
* @param [string] $label Promp printed to STDOUT
* @param [mixed] $default Returns if no other choice
*
* @return [string] Either $args[$key]. $default, or string from prompt
*/
public static function string($args, $key, $label = "Enter", $default = null)
{
if (isset($args[$key])) {
return $args[$key];
}
$string = \Terminus::prompt($label);
if ($string == '' && isset($default)) {
return $default;
}
return $string;
}
示例6: lock
/**
* Lock an environment to prevent changes
*
* ## OPTIONS
*
* <info|add|remove>
* : action to execute ( i.e. info, add, remove )
*
* [--site=<site>]
* : site name
*
* [--env=<env>]
* : site environment
*
* [--username=<username>]
* : your username
*
* [--password=<password>]
* : your password
*
**/
function lock($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::site($assoc_args));
$env = Input::env($assoc_args, 'env');
switch ($action) {
case 'info':
$data = $locks = $site->environment($env)->lockinfo();
if (!Terminus::get_config('json')) {
$data = array($data);
}
$this->handleDisplay($data);
break;
case 'add':
Terminus::line("Creating new lock on %s -> %s", array($site->getName(), $env));
if (!isset($assoc_args['username'])) {
$email = Terminus::prompt("Username for the lock");
} else {
$email = $assoc_args['username'];
}
if (!isset($assoc_args['password'])) {
exec("stty -echo");
$password = Terminus::prompt("Password for the lock");
exec("stty echo");
Terminus::line();
} else {
$password = $assoc_args['password'];
}
$data = $site->environment($env)->lock($email, $password);
if ($data and property_exists($data, 'id')) {
$this->waitOnWorkflow('sites', $data->site_id, $data->id);
}
Terminus::success('Success');
break;
case 'remove':
Terminus::line("Removing lock from %s -> %s", array($site->getName(), $env));
$data = $site->environment($env)->unlock();
if (property_exists($data, 'id')) {
$this->waitOnWorkflow('sites', $data->site_id, $data->id);
}
Terminus::success('Success');
}
}
示例7: lock
/**
* Lock an environment to prevent changes
*
* ## OPTIONS
*
* <info|add|remove>
* : action to execute ( i.e. info, add, remove )
*
* [--site=<site>]
* : site name
*
* [--env=<env>]
* : site environment
*
* [--username=<username>]
* : your username
*
* [--password=<password>]
* : your password
*
**/
function lock($args, $assoc_args)
{
$action = array_shift($args);
$site = $this->sites->get(Input::sitename($assoc_args));
$env = $site->environments->get(Input::env($assoc_args, 'env'));
switch ($action) {
case 'info':
$info = $env->lockinfo();
$this->output()->outputRecord($info);
break;
case 'add':
$this->log()->info('Creating new lock on {site}-{env}', array('site' => $site->get('name'), 'env' => $env->get('id')));
if (!isset($assoc_args['username'])) {
$username = Terminus::prompt('Username for the lock');
} else {
$username = $assoc_args['username'];
}
if (!isset($assoc_args['password'])) {
$password = Terminus::promptSecret('Password for the lock');
} else {
$password = $assoc_args['password'];
}
$workflow = $env->lock(array('username' => $username, 'password' => $password));
$workflow->wait();
break;
case 'remove':
$this->log()->info('Removing lock from {site}-{env}', array('site' => $site->get('name'), 'env' => $env->get('id')));
$workflow = $env->unlock();
$workflow->wait();
break;
}
if (isset($workflow)) {
$this->workflowOutput($workflow);
}
}
示例8: lock
/**
* Lock an environment to prevent changes
*
* ## OPTIONS
*
* <info|add|remove>
* : action to execute ( i.e. info, add, remove )
*
* [--site=<site>]
* : site name
*
* [--env=<env>]
* : site environment
*
* [--username=<username>]
* : your username
*
* [--password=<password>]
* : your password
*
**/
function lock($args, $assoc_args)
{
$action = array_shift($args);
$site = SiteFactory::instance(Input::sitename($assoc_args));
$env = Input::env($assoc_args, 'env');
switch ($action) {
case 'info':
$info = $site->environment($env)->lockinfo();
return $this->handleDisplay($info);
case 'add':
Terminus::line("Creating new lock on %s -> %s", array($site->getName(), $env));
if (!isset($assoc_args['username'])) {
$username = Terminus::prompt("Username for the lock");
} else {
$username = $assoc_args['username'];
}
if (!isset($assoc_args['password'])) {
exec("stty -echo");
$password = Terminus::prompt("Password for the lock");
exec("stty echo");
Terminus::line();
} else {
$password = $assoc_args['password'];
}
$workflow = $site->environment($env)->lock(array('username' => $username, 'password' => $password));
$workflow->wait();
return Terminus::success('Success');
case 'remove':
Terminus::line("Removing lock from %s -> %s", array($site->getName(), $env));
$workflow = $site->environment($env)->unlock();
$workflow->wait();
return Terminus::success('Success');
}
}
示例9: promptSecret
/**
* Prompt the user for input
*
* @param string $message
*/
static function promptSecret($message = '', $params = array(), $default = null)
{
exec("stty -echo");
$response = Terminus::prompt($message, $params);
exec("stty echo");
Terminus::line();
return $response;
}
示例10: string
static function string($args, $key, $label = "Enter", $default = null)
{
if (isset($args[$key])) {
return $args[$key];
}
$string = \Terminus::prompt($label);
if ('' == $string and null !== $default) {
return $default;
}
return $string;
}