summaryrefslogtreecommitdiff
path: root/utils/rhrd-pool
diff options
context:
space:
mode:
Diffstat (limited to 'utils/rhrd-pool')
-rwxr-xr-xutils/rhrd-pool29
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") {