diff options
author | Christian Pointner <equinox@helsinki.at> | 2016-07-29 17:02:10 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2016-07-29 17:02:10 (GMT) |
commit | 963e198bd05da3e5ba5affbff759c0ec50456b5e (patch) | |
tree | b9ffffe3b0496e61a8f200b32a5e68868bec4be5 /utils | |
parent | 63439f9f734710f9f96523a9cbb8bb9728b4647d (diff) |
implemented create musicpool group
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/rhrd-pool | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/utils/rhrd-pool b/utils/rhrd-pool index 69bc702..618c3e7 100755 --- a/utils/rhrd-pool +++ b/utils/rhrd-pool @@ -30,7 +30,7 @@ sub print_usage { print STDERR "Usage: rhrd-pool list\n" . " rhrd-pool (show|remove) <short-name>\n" . - " rhrd-pool add <short-name> <groupname> <title>\n" . + " rhrd-pool add <groupname> <title>\n" . " rhrd-pool edit <short-name> <title>\n"; } @@ -65,7 +65,7 @@ sub show sub add__check_arguments { - my ($groupname, $shortname, $title) = @_; + my ($groupname, $title) = @_; if($groupname !~ m/^[-a-zA-Z0-9_]{1,10}$/) { print STDERR "name '" . $groupname . "' contains illegal characters or is too long/short\n"; @@ -73,24 +73,19 @@ sub add__check_arguments return 1; } - if($shortname !~ m/^P([0-9]{2})$/) { - print STDERR "short name '" . $shortname . "' must be a value between P00 and P99\n"; - return 1; - } - my $color = RHRD::utils::POOL_COLORS->[int($1)]; - return 0, $color; + return 0; } sub add { - my ($ctx, $shortname, $groupname, $title) = @_; + my ($ctx, $groupname, $title) = @_; - my ($ret, $color) = add__check_arguments($groupname, $shortname, $title); + my ($ret) = add__check_arguments($groupname, $title); if($ret) { return $ret; } - print " * creating pool: '" . $title . "' (" . $shortname . ") with group '" . $groupname . "'\n"; + print " * creating pool: '" . $title . "' with group '" . $groupname . "'\n"; my ($result, $status, $errorstring) = RHRD::rddb::check_group($ctx, $groupname); unless(defined $result) { @@ -102,12 +97,14 @@ sub add return 1 } - print " * creating group '" . $groupname . "'\n"; - ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_group($ctx, $groupname); - unless(defined $result) { + (my $num, $status, $errorstring) = RHRD::rddb::create_musicpool_group($ctx, $groupname); + unless(defined $num) { print STDERR $status . ": " . $errorstring . "\n"; return 1; } + my $shortname = sprintf("P%02d", $num); + my $color = RHRD::utils::get_musicpool_color($num); + print " * created group '" . $groupname . "' --> pool shortname / color: " . $shortname . " / " . $color . "\n"; ($result, $status, $errorstring) = RHRD::rddb::create_musicpool_event($ctx, $shortname, $groupname); unless(defined $result) { @@ -205,11 +202,11 @@ if(defined $ctx) { } } elsif($cmd eq "add") { - if($num_args != 4) { + if($num_args != 3) { print_usage(); $ret = 1; } else { - $ret = add($ctx, $ARGV[1], $ARGV[2], $ARGV[3]); + $ret = add($ctx, $ARGV[1], $ARGV[2]); } } elsif($cmd eq "edit") { |