PHP Class Cml\Console\Component\Dialog

Mostrar archivo Open project: linhecheng/cmlphp Class Usage Examples

Public Methods

Method Description
ask ( string $question, boolean $isHidden = false, string $default = '', boolean $displayDefault = true ) : string 提问并获取用户输入
confirm ( string $question, array $choices = ['Y', 'n'], string $answer = 'y', string $default = 'y', string $errorMessage = 'Invalid choice' ) : boolean 确认对话框

Private Methods

Method Description
askHidden ( ) : string 隐藏输入如密码等
getShell ( ) : string | boolean Returns a valid unix shell.
hasSttyAvailable ( ) : boolean stty是否可用

Method Details

ask() public method

提问并获取用户输入
public ask ( string $question, boolean $isHidden = false, string $default = '', boolean $displayDefault = true ) : string
$question string 问题
$isHidden boolean 是否要隐藏输入
$default string 默认答案
$displayDefault boolean 是否显示默认答案
return string

confirm() public method

if($dialog->confirm('Are you sure?')) { ... } if($dialog->confirm('Your choice?', null, ['a', 'b', 'c'])) { ... }
public confirm ( string $question, array $choices = ['Y', 'n'], string $answer = 'y', string $default = 'y', string $errorMessage = 'Invalid choice' ) : boolean
$question string 问题
$choices array 选项
$answer string 通过的答案
$default string 默认选项
$errorMessage string 错误信息
return boolean