pldb: Correct the usage for the `list' command.
[dvddb] / pldb
diff --git a/pldb b/pldb
index 2e70b6c..631e544 100755 (executable)
--- a/pldb
+++ b/pldb
@@ -44,7 +44,7 @@ sub db_connect (;$) {
              RaiseError => 1,
              ReadOnly => 1,
              %$opts);
-  $DB = DBI->connect("dbi:Pg:host=roadstar", "", "", \%opts);
+  $DB = DBI->connect("dbi:Pg:host=roadstar;dbname=mdw", "", "", \%opts);
 }
 
 sub must_exist ($$@) {
@@ -123,7 +123,7 @@ defcmd "edit GROUP LIST[[+|-]=POS]|-LIST ...", sub {
   my $st_del = $DB->prepare
     ("DELETE FROM playlist_position WHERE group_name = ? AND list_name = ?");
 
-  for my $op (@ops) {
+  OP: for my $op (@ops) {
     if ($op =~ /^ - (.++) $/x) {
       my ($list) = ($1);
       must_list $list; must_member $group, $list;
@@ -143,8 +143,10 @@ defcmd "edit GROUP LIST[[+|-]=POS]|-LIST ...", sub {
        @r or die "`$list' is not a member of `$group'";
        my ($cur) = @r; $st_getpos->finish;
 
-       if ($rel eq "+") { $pos = $cur + $pos; }
-       elsif ($rel eq "-") { $pos = $cur - $pos; }
+       my $end;
+       if ($rel eq "+") { $pos = $cur + $pos; $end = $n; }
+       elsif ($rel eq "-") { $pos = $cur - $pos; $end = 0; }
+       if ($pos == $end) { $st_del->execute($group, $list); next OP; }
       }
       0 <= $pos && $pos < $n
        or die "`$list' position $pos out of range 0 .. $n";
@@ -258,7 +260,7 @@ defcmd "next [-pu] [-o N] [-n N] GROUP [LIST]", sub {
   defined $prevlist and print "$prevlist\n", map "\t$_\n", @out;
 };
 
-defcmd "list LIST", sub {
+defcmd "list [-g [MARK=]GROUP,...] [-r [LO][-[HI]]] LIST", sub {
   local @ARGV = @_;
   my $bogusp = 0;
   my %opt;