]> git.proxmox.com Git - pve-installer.git/blob - Proxmox/UI/StdIO.pm
75ddbeb6924d81e25710e7c469b426bcca01984c
[pve-installer.git] / Proxmox / UI / StdIO.pm
1 package Proxmox::UI::StdIO;
2
3 use strict;
4 use warnings;
5
6 use base qw(Proxmox::UI::Base);
7
8 use Proxmox::Log;
9
10 sub init {
11 my ($self) = @_;
12
13 STDOUT->autoflush(1);
14 }
15
16 sub message {
17 my ($self, $msg) = @_;
18
19 print STDOUT "message: $msg\n";
20 }
21
22 sub error {
23 my ($self, $msg) = @_;
24 log_err("error: $msg\n");
25 print STDOUT "error: $msg\n";
26 }
27
28 sub finished {
29 my ($self, $success, $msg) = @_;
30
31 my $state = $success ? 'ok' : 'err';
32 log_info("finished: $state, $msg\n");
33 print STDOUT "finished: $state, $msg\n";
34 }
35
36 sub prompt {
37 my ($self, $query) = @_;
38
39 $query =~ s/\n/ /g; # FIXME: use a better serialisation (e.g., JSON)
40 print STDOUT "prompt: $query\n";
41
42 my $response = <STDIN> // ''; # FIXME: error handling?
43
44 chomp($response);
45
46 return lc($response) eq 'ok';
47 }
48
49 sub display_html {
50 my ($raw_html, $html_dir) = @_;
51
52 # ignore for now
53 }
54
55 sub progress {
56 my ($self, $ratio, $text) = @_;
57
58 $text = '' if !defined($text);
59
60 print STDOUT "progress: $ratio $text\n";
61 }
62
63 sub process_events {
64 my ($self) = @_;
65
66 # nothing to do for now?
67 }
68
69 1;