Permalink
Browse files

[14] Implemented possibilty of prompting user input

Signed-off-by: DoesntMatter <jaed1@gmx.net>
  • Loading branch information...
DoesntMatter committed Jan 22, 2012
1 parent 459db2b commit 0cd1f573c6d30894549d6fd49f43c0bdf979564c
Showing with 40 additions and 11 deletions.
  1. +40 −11 gitlog_to_rss.pl
View
@@ -35,28 +35,36 @@
\%options,
"repo=s",
"outfile=s",
"prompt",
"help|?",
);
#
# Check and set options
#
if ($options{'help'}) {
ShowHelp();
}
if ($options{'repo'} and $options{'repo'} ne '') {
unless (CheckRepo($options{'repo'})) {
unless ($options{'prompt'}) {
if ($options{'help'}) {
ShowHelp();
}
if ($options{'repo'} and $options{'repo'} ne '') {
unless (CheckRepo($options{'repo'})) {
ShowHelp();
}
}
else {
ShowHelp();
}
unless ($options{'outfile'} and $options{'outfile'} ne '') {
$options{'outfile'} = cwd() . "/feed.rss";
}
}
else {
ShowHelp();
}
unless ($options{'outfile'} and $options{'outfile'} ne '') {
$options{'outfile'} = cwd() . "/feed.rss";
$options{'repo'} = GetInput("Please enter repository path: ", 1);
unless (CheckRepo($options{'repo'})) {
ShowHelp();
}
$options{'outfile'} = GetInput("Please enter outfile path: ");
}
#
@@ -85,12 +93,33 @@ sub ShowHelp {
Options:
--repo REPO Path to your Git repository
--outfile FILE Name and path of generated RSS file
--prompt Prompt for input and do not use options
--help Show this output
HELP
exit;
};
sub GetInput {
my $text = shift || return undef;
my $mandatory = shift || 0;
my $input;
if ($mandatory) {
until ($input) {
print STDERR $text;
$input = <>;
chomp($input);
}
}
else {
print STDERR $text;
$input = <>;
chomp($input);
}
return $input;
}
sub CheckRepo {
my $repo = shift || return undef;

0 comments on commit 0cd1f57

Please sign in to comment.