mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-26 19:54:46 +01:00
LScli : add confirm helper method
This commit is contained in:
parent
0d916d3d0d
commit
1de6d1d25e
1 changed files with 21 additions and 0 deletions
|
@ -295,6 +295,27 @@ class LScli extends LSlog_staticLoggerClass {
|
||||||
return array($return_value, $stdout, $stderr);
|
return array($return_value, $stdout, $stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLI helper to ask for user confirmation
|
||||||
|
*
|
||||||
|
* @param[in] $question string The confirmation question (optional, default: "Are you sure?")
|
||||||
|
*
|
||||||
|
* @retval boolean True if user confirmed, false otherwise
|
||||||
|
**/
|
||||||
|
public static function confirm($question=null) {
|
||||||
|
if (is_null($question))
|
||||||
|
$question = "Are you sure?";
|
||||||
|
echo "\n$question Type 'yes' to continue: ";
|
||||||
|
$handle = fopen ("php://stdin","r");
|
||||||
|
$line = fgets($handle);
|
||||||
|
if(trim($line) != 'yes'){
|
||||||
|
echo "User cancel\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue