@@ -14,36 +14,32 @@ class TransferIssuesCommand extends ReportCommand {
1414 TransferIssuesCommand ()
1515 : super ('transfer-issues' ,
1616 'Bulk transfer issues from one repo to another.' ) {
17- argParser.addFlag (
18- 'apply-changes' ,
19- negatable: false ,
20- help: 'WARNING: This will transfer the issues. Please preview the changes'
21- "first by running without '--apply-changes'." ,
22- defaultsTo: false ,
23- );
24- argParser.addMultiOption (
25- 'issues' ,
26- valueHelp: '1,2,3' ,
27- help: 'Specifiy the numbers of specific issues to transfer, otherwise'
28- ' transfers all.' ,
29- );
30- argParser.addOption (
31- 'source-repo' ,
32- valueHelp: 'repo-org/repo-name' ,
33- help: 'The source repository for the issues to be moved from.' ,
34- mandatory: true ,
35- );
36- argParser.addOption (
37- 'target-repo' ,
38- valueHelp: 'repo-org/repo-name' ,
39- help: 'The target repository name where the issues will be moved to.' ,
40- mandatory: true ,
41- );
42- argParser.addOption (
43- 'add-label' ,
44- help: 'Add a label to all transferred issues.' ,
45- valueHelp: 'package:foo' ,
46- );
17+ argParser
18+ ..addFlag (
19+ 'apply-changes' ,
20+ negatable: false ,
21+ help:
22+ 'WARNING: This will transfer the issues. Please preview the changes'
23+ "first by running without '--apply-changes'." ,
24+ defaultsTo: false ,
25+ )
26+ ..addOption (
27+ 'source-repo' ,
28+ valueHelp: 'repo-org/repo-name' ,
29+ help: 'The source repository for the issues to be moved from.' ,
30+ mandatory: true ,
31+ )
32+ ..addOption (
33+ 'target-repo' ,
34+ valueHelp: 'repo-org/repo-name' ,
35+ help: 'The target repository name where the issues will be moved to.' ,
36+ mandatory: true ,
37+ )
38+ ..addOption (
39+ 'add-label' ,
40+ help: 'Add a label to all transferred issues.' ,
41+ valueHelp: 'package:foo' ,
42+ );
4743 }
4844
4945 @override
@@ -52,13 +48,12 @@ class TransferIssuesCommand extends ReportCommand {
5248
5349 @override
5450 Future <int > run () async {
55- var applyChanges = argResults! ['apply-changes' ] as bool ;
51+ var parsedArgs = argResults! ;
52+ var applyChanges = parsedArgs.flag ('apply-changes' );
5653
57- var sourceRepo = argResults ! [ 'source-repo' ] as String ;
58- var targetRepo = argResults ! [ 'target-repo' ] as String ;
54+ var sourceRepo = parsedArgs. option ( 'source-repo' ) ! ;
55+ var targetRepo = parsedArgs. option ( 'target-repo' ) ! ;
5956
60- var issueNumberString = argResults! ['issues' ] as List <String >? ;
61- var issueNumbers = issueNumberString? .map (int .parse).toList ();
6257 var labelName = argResults! ['add-label' ] as String ? ;
6358
6459 if (! applyChanges) {
@@ -68,7 +63,6 @@ class TransferIssuesCommand extends ReportCommand {
6863 return await transferAndLabelIssues (
6964 RepositorySlug .full (sourceRepo),
7065 RepositorySlug .full (targetRepo),
71- issueNumbers,
7266 labelName,
7367 applyChanges,
7468 );
@@ -77,7 +71,6 @@ class TransferIssuesCommand extends ReportCommand {
7771 Future <int > transferAndLabelIssues (
7872 RepositorySlug sourceRepo,
7973 RepositorySlug targetRepo, [
80- List <int >? issueNumbers,
8174 String ? labelName,
8275 bool applyChanges = false ,
8376 ]) async {
@@ -118,10 +111,7 @@ class TransferIssuesCommand extends ReportCommand {
118111 return 0 ;
119112 }
120113
121- Future <List <String >> getIssueIds (
122- RepositorySlug slug, [
123- List <int >? issueNumbers,
124- ]) async {
114+ Future <List <String >> getIssueIds (RepositorySlug slug) async {
125115 final queryString = '''query {
126116 repository(owner:"${slug .owner }", name:"${slug .name }") {
127117 issues(last:100) {
@@ -144,9 +134,6 @@ class TransferIssuesCommand extends ReportCommand {
144134 var nodes = issues['nodes' ] as List ;
145135 return nodes
146136 .map ((node) => node as Map )
147- .where ((node) => issueNumbers != null
148- ? issueNumbers.contains (node['number' ] as int )
149- : true )
150137 .map ((node) => node['id' ] as String )
151138 .toList ();
152139 },
0 commit comments