1 package Object::Remote::Prompt;
7 our @EXPORT = qw(prompt prompt_pw);
9 our ($prompt, $prompt_pw);
12 _local_prompt_core(0, @_);
15 sub _local_prompt_pw {
16 _local_prompt_core(1, @_);
21 sub _local_prompt_core {
22 my ($pw, $message, $default, $opts) = @_;
24 if ($opts->{cache} and my $hit = $Prompt_Cache{$message}) {
30 system('stty -echo') if $pw;
32 print STDOUT "${message}: ";
33 chomp(my $res = <STDIN>);
35 print STDOUT "\n" if $pw;
36 system('stty echo') if $pw;
38 $Prompt_Cache{$message} = $res if $opts->{cache};
44 die "User input wanted - $_[0] - but no prompt available"
50 die "User input wanted - $_[0] - but no password prompt available"
56 $prompt = \&_local_prompt;
57 $prompt_pw = \&_local_prompt_pw;
60 sub set_local_prompt_command {
61 ($prompt, $prompt_pw) = @_;
65 sub maybe_set_prompt_command_on {
66 return unless $prompt;
68 $conn->remote_sub('Object::Remote::Prompt::set_local_prompt_command')
69 ->($prompt, $prompt_pw);