Hello community,
here is the log from the commit of package perl-Sysadm-Install for
openSUSE:Factory checked in at 2015-06-30 10:18:14
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-Sysadm-Install (Old)
and /work/SRC/openSUSE:Factory/.perl-Sysadm-Install.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-Sysadm-Install"
Changes:
--------
--- /work/SRC/openSUSE:Factory/perl-Sysadm-Install/perl-Sysadm-Install.changes
2015-06-09 12:25:07.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.perl-Sysadm-Install.new/perl-Sysadm-Install.changes
2015-06-30 10:18:16.000000000 +0200
@@ -1,0 +2,10 @@
+Sat Jun 27 08:59:12 UTC 2015 - [email protected]
+
+- updated to 0.46
+ see /usr/share/doc/packages/perl-Sysadm-Install/Changes
+
+ 0.46 (2015/06/23)
+ (ms) ask() and pick() now support getting the user's response on the
+ tty, instead of stdin, so they can be used from within a pipe.
+
+-------------------------------------------------------------------
Old:
----
Sysadm-Install-0.45.tar.gz
New:
----
Sysadm-Install-0.46.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-Sysadm-Install.spec ++++++
--- /var/tmp/diff_new_pack.nSNW4O/_old 2015-06-30 10:18:16.000000000 +0200
+++ /var/tmp/diff_new_pack.nSNW4O/_new 2015-06-30 10:18:16.000000000 +0200
@@ -17,7 +17,7 @@
Name: perl-Sysadm-Install
-Version: 0.45
+Version: 0.46
Release: 0
%define cpan_name Sysadm-Install
Summary: Typical installation tasks for system administrators
++++++ Sysadm-Install-0.45.tar.gz -> Sysadm-Install-0.46.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/Changes
new/Sysadm-Install-0.46/Changes
--- old/Sysadm-Install-0.45/Changes 2015-05-26 07:17:33.000000000 +0200
+++ new/Sysadm-Install-0.46/Changes 2015-06-24 05:00:19.000000000 +0200
@@ -2,6 +2,10 @@
Revision history for Sysadm::Install
########################################
+0.46 (2015/06/23)
+ (ms) ask() and pick() now support getting the user's response on the
+ tty, instead of stdin, so they can be used from within a pipe.
+
0.45 (2015/05/25)
(ms) Alexandr Ciornii fixed manifest and tests for the Windows platform
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/META.json
new/Sysadm-Install-0.46/META.json
--- old/Sysadm-Install-0.45/META.json 2015-05-26 07:18:15.000000000 +0200
+++ new/Sysadm-Install-0.46/META.json 2015-06-24 05:02:18.000000000 +0200
@@ -50,5 +50,5 @@
"url" : "http://github.com/mschilli/sysadm-install-perl"
}
},
- "version" : "0.45"
+ "version" : "0.46"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/META.yml
new/Sysadm-Install-0.46/META.yml
--- old/Sysadm-Install-0.45/META.yml 2015-05-26 07:18:15.000000000 +0200
+++ new/Sysadm-Install-0.46/META.yml 2015-06-24 05:02:18.000000000 +0200
@@ -29,4 +29,4 @@
Term::ReadKey: '0'
resources:
repository: http://github.com/mschilli/sysadm-install-perl
-version: '0.45'
+version: '0.46'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/README
new/Sysadm-Install-0.46/README
--- old/Sysadm-Install-0.45/README 2015-05-26 07:18:14.000000000 +0200
+++ new/Sysadm-Install-0.46/README 2015-06-24 05:02:18.000000000 +0200
@@ -1,5 +1,5 @@
######################################################################
- Sysadm::Install 0.45
+ Sysadm::Install 0.46
######################################################################
NAME
@@ -83,7 +83,7 @@
Untar the tarball in $tgz_file in directory $dir. Create $dir if it
doesn't exist yet.
- "pick($prompt, $options, $default)"
+ "pick($prompt, $options, $default, $opts)"
Ask the user to pick an item from a displayed list. $prompt is the
text displayed, $options is a referenc to an array of choices, and
$default is the number (starting from 1, not 0) of the default item.
@@ -105,10 +105,16 @@
If the user enters 1, 2 or 3, the corresponding text string
("apple", "pear", "pineapple" will be returned by "pick()".
- "ask($prompt, $default)"
+ If the optional $opts hash has "{ tty => 1 }" set, then the user
+ reponse will be expected from the console, not STDIN.
+
+ "ask($prompt, $default, $opts)"
Ask the user to either hit *Enter* and select the displayed default
or to type in another string.
+ If the optional $opts hash has "{ tty => 1 }" set, then the user
+ reponse will be expected from the console, not STDIN.
+
"mkd($dir)"
Create a directory of arbitrary depth, just like
"File::Path::mkpath".
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/eg/ask
new/Sysadm-Install-0.46/eg/ask
--- old/Sysadm-Install-0.45/eg/ask 2014-05-07 08:37:21.000000000 +0200
+++ new/Sysadm-Install-0.46/eg/ask 2015-06-24 04:57:50.000000000 +0200
@@ -8,9 +8,9 @@
use Sysadm::Install qw(ask pick);
-my $name = ask("Type in your name", "Joe");
+my $name = ask("Type in your name", "Joe", {tty => 1});
print "Your name is $name.\n";
-my $fruit = pick("Pick a fruit", ["apple", "pear", "pineapple"], 3);
+my $fruit = pick("Pick a fruit", ["apple", "pear", "pineapple"],
+ 3, {tty => 1});
print "Your picked $fruit.\n";
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/Sysadm-Install-0.45/lib/Sysadm/Install.pm
new/Sysadm-Install-0.46/lib/Sysadm/Install.pm
--- old/Sysadm-Install-0.45/lib/Sysadm/Install.pm 2015-05-26
07:17:39.000000000 +0200
+++ new/Sysadm-Install-0.46/lib/Sysadm/Install.pm 2015-06-24
04:58:31.000000000 +0200
@@ -6,7 +6,7 @@
use strict;
use warnings;
-our $VERSION = '0.45';
+our $VERSION = '0.46';
use File::Copy;
use File::Path;
@@ -365,7 +365,7 @@
=pod
-=item C<pick($prompt, $options, $default)>
+=item C<pick($prompt, $options, $default, $opts)>
Ask the user to pick an item from a displayed list. C<$prompt>
is the text displayed, C<$options> is a referenc to an array of
@@ -389,12 +389,15 @@
(C<"apple">, C<"pear">, C<"pineapple"> will be returned by
C<pick()>.
+If the optional C<$opts> hash has C<{ tty =E<gt> 1 }> set, then
+the user reponse will be expected from the console, not STDIN.
+
=cut
##################################################
sub pick {
##################################################
- my ($prompt, $options, $default) = @_;
+ my ($prompt, $options, $default, $opts) = @_;
local $Log::Log4perl::caller_depth =
$Log::Log4perl::caller_depth + 1;
@@ -402,23 +405,23 @@
my $default_int;
my %files;
- if(@_ != 3 or ref($options) ne "ARRAY") {
+ if(@_ < 3 or ref($options) ne "ARRAY") {
LOGCROAK("pick called with wrong #/type of args");
}
{
my $count = 0;
+ my $user_prompt = "";
+
foreach (@$options) {
- print STDERR "[", ++$count, "] $_\n";
+ $user_prompt .= "[" . ++$count . "] $_\n";
$default_int = $count if $count eq $default;
$files{$count} = $_;
}
- print STDERR "$prompt [$default_int]> "
- or die "Couldn't write STDERR: ($!)";
- my $input = <STDIN>;
- chomp($input) if defined $input;
+ $user_prompt .= "$prompt [$default_int]> ";
+ my $input = user_input($user_prompt, $opts);
$input = $default_int if !defined $input or !length($input);
@@ -431,36 +434,58 @@
=pod
-=item C<ask($prompt, $default)>
+=item C<ask($prompt, $default, $opts)>
Ask the user to either hit I<Enter> and select the displayed default
or to type in another string.
+If the optional C<$opts> hash has C<{ tty =E<gt> 1 }> set, then
+the user reponse will be expected from the console, not STDIN.
+
=cut
##################################################
sub ask {
##################################################
- my ($prompt, $default) = @_;
+ my ($prompt, $default, $opts) = @_;
+
+ $opts = {} if !defined $opts;
local $Log::Log4perl::caller_depth =
$Log::Log4perl::caller_depth + 1;
- if(@_ != 2) {
+ if(@_ < 2) {
LOGCROAK("ask() called with wrong # of args");
}
- print STDERR "$prompt [$default]> "
- or die "Couldn't write STDERR: ($!)";
-
- my $value = <STDIN>;
- chomp $value;
-
+ my $value = user_input("$prompt [$default]> ", $opts);
$value = $default if $value eq "";
return $value;
}
+##################################################
+sub user_input {
+##################################################
+ my ($prompt, $opts) = @_;
+
+ $opts = {} if !defined $opts;
+
+ my $fh = *STDIN;
+ if( $opts->{ tty } ) {
+ open $fh, "<", '/dev/tty' or
+ die "Cannot open /dev/tty ($!)";
+ }
+
+ print STDERR $prompt
+ or die "Couldn't write STDERR: ($!)";
+
+ my $input = <$fh>;
+ chomp $input if defined $input;
+
+ return $input;
+}
+
=pod
=item C<mkd($dir)>