From 98007830ee0282a58e6604632df350bf60636748 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Fri, 2 Oct 2015 10:45:58 +0200 Subject: [PATCH] make read_password a CLIHandler class method And use new run_cli_handler() method. --- PVE/CLI/pveum.pm | 12 ++++++++++++ pveum | 15 +-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/PVE/CLI/pveum.pm b/PVE/CLI/pveum.pm index 772ba29..b12a0bd 100755 --- a/PVE/CLI/pveum.pm +++ b/PVE/CLI/pveum.pm @@ -21,6 +21,18 @@ use PVE::CLIHandler; use base qw(PVE::CLIHandler); +sub read_password { + # return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET}); + + my $term = new Term::ReadLine ('pveum'); + my $attribs = $term->Attribs; + $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; + my $input = $term->readline('Enter new password: '); + my $conf = $term->readline('Retype new password: '); + die "Passwords do not match.\n" if ($input ne $conf); + return $input; +} + our $cmddef = { ticket => [ 'PVE::API2::AccessControl', 'create_ticket', ['username'], undef, sub { diff --git a/pveum b/pveum index 4ab2e0c..196fb3a 100755 --- a/pveum +++ b/pveum @@ -5,22 +5,9 @@ use warnings; use PVE::CLI::pveum; -my $read_password = sub { - - # return $ENV{PVE_PW_TICKET} if defined($ENV{PVE_PW_TICKET}); - - my $term = new Term::ReadLine ('pveum'); - my $attribs = $term->Attribs; - $attribs->{redisplay_function} = $attribs->{shadow_redisplay}; - my $input = $term->readline('Enter new password: '); - my $conf = $term->readline('Retype new password: '); - die "Passwords do not match.\n" if ($input ne $conf); - return $input; -}; - my $prepare = sub { # autmatically generate the private key if it does not already exists PVE::Cluster::gen_auth_key(); }; -PVE::CLI::pveum->run_cli($read_password, undef, $prepare); +PVE::CLI::pveum->run_cli_handler(prepare => $prepare); -- 2.39.2