Permalink
Browse files

Add --force option to shrtn, for updating an existing mapping.

  • Loading branch information...
1 parent 9609016 commit 4ec905a9c643a6533516194ac13a6009647110f2 @gavincarr committed Oct 12, 2014
Showing with 5 additions and 3 deletions.
  1. +5 −3 shrtn
View
@@ -25,10 +25,11 @@ sub usage {
$|++;
my $verbose = 0;
-my ($help, $noop);
+my ($help, $force);
usage unless GetOptions(
'help|h|?' => \$help,
'verbose|v+' => \$verbose,
+ 'force|f' => \$force,
);
usage if $help;
usage if ! @ARGV;
@@ -49,8 +50,9 @@ my $base_url = $config->{base_url}
or die "No base_url setting found in config.yml\n";
if ($code) {
- # Check if $code is available in $db, dying if not
- shortcode_available($code, $db, $url, { base_url => $base_url, die => 1 });
+ # Check if $code is available in $db, dying if not (unless $force is set)
+ my $die = $force ? 0 : 1;
+ shortcode_available($code, $db, $url, { base_url => $base_url, die => $die });
}
else {
# Generate new shortcode for $url

0 comments on commit 4ec905a

Please sign in to comment.