-
-
Save AlexDaniel/2c62bc0e92b13f1030496b65ca550f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl6 | |
# example usage: | |
# ./populate-issues.p6 "I know what I'm doing" YOUR-ACCESS-TOKEN A000005 A000007 | |
# Based on this script: https://github.com/perl6/ecosystem-unbitrot/blob/master/scripts/populate-issues.p6 | |
my $repo = ‘ajs/perl6-Math-Sequences’; | |
my $url = “https://api.github.com/repos/$repo/issues”; | |
sub body-template($entry) { | |
qq:to/TEMPLATE/ | |
Sequence [{$entry.ID} / {$entry.name}](https://oeis.org/{$entry.ID}) is not implemented yet. | |
{$entry.sequence} | |
Keywords: {$entry.keywords} | |
TEMPLATE | |
} | |
multi MAIN(‘I know what I'm doing’, $token, *@seqs) { | |
for @seqs { | |
use OEIS; | |
my $entry = OEIS::lookup: $_; | |
exit unless $entry; | |
my $number = submit-issue :$token, | |
title => “{$entry.ID} / {$entry.name}”, | |
body => body-template $entry,; | |
put “$number, $_”; | |
sleep 5; | |
} | |
} | |
multi MAIN(*@) { | |
note ‘Exiting… Please confirm your intentions.’; | |
} | |
sub submit-issue(:$token, :$title, :$body, :@labels) { | |
my %body = %(:$title, :$body, :@labels,); | |
use Cro::HTTP::Client; | |
my $resp = await Cro::HTTP::Client.post: $url, | |
headers => [ | |
User-Agent => ‘perl6 ecosystem unbitrot’, | |
Authorization => “token $token”, | |
], | |
content-type => ‘application/json’, | |
body => %body, | |
; | |
return (await $resp.body)<number> # issue number | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment