pve-installer/Proxmox/UI/StdIO.pm
Christoph Heiss 0c4590e073 UI: turn on autoflush for STDOUT
Otherwise, when STDOUT is connected to a pipe, it will not get flushed
completely after each message, which might than hangs the installer UI.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2023-06-20 16:07:15 +02:00

57 lines
768 B
Perl

package Proxmox::UI::StdIO;
use strict;
use warnings;
use base qw(Proxmox::UI::Base);
sub init {
my ($self) = @_;
STDOUT->autoflush(1);
}
sub message {
my ($self, $msg) = @_;
print STDOUT "message: $msg\n";
}
sub error {
my ($self, $msg) = @_;
print STDOUT "error: $msg\n";
}
sub prompt {
my ($self, $query) = @_;
print STDOUT "prompt: $query\n";
my $response = <STDIN> // ''; # FIXME: error handling?
chomp($response);
return lc($response) eq 'ok';
}
sub display_html {
my ($raw_html, $html_dir) = @_;
# ignore for now
}
sub progress {
my ($self, $ratio, $text) = @_;
print STDOUT "progress: $ratio $text\n";
}
sub process_events {
my ($self) = @_;
# nothing to do for now?
}
1;