summaryrefslogtreecommitdiffstats
path: root/contrib/issue-api-key.pl
blob: fe24f59dfa50bf8f6b2419cbffb94898e028d34c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -w
use strict;
use feature 'say';

use FindBin qw( $RealBin );
use lib "$RealBin/..";
use lib "$RealBin/../lib";

use Bugzilla;
use Bugzilla::Constants;
use Bugzilla::User;
use Bugzilla::User::APIKey;

Bugzilla->usage_mode(USAGE_MODE_CMDLINE);

my $login = shift
    or die "syntax: $0 bugzilla-login [description]\n";
my $description = shift;

my $user = Bugzilla::User->check({ name => $login });
my $api_key = Bugzilla::User::APIKey->create({
    user_id     => $user->id,
    description => $description,
});
say $api_key->api_key;