@@ -35,7 +35,7 @@ private static int Main(string[] args)
35
35
36
36
var fileSystem = new FileSystem ( ) ;
37
37
38
- return Parser . Default . ParseArguments < CreateSubOptions , AddAssetSubOptions , CloseSubOptions , PublishSubOptions , ExportSubOptions , InitSubOptions , ShowConfigSubOptions > ( args )
38
+ return Parser . Default . ParseArguments < CreateSubOptions , AddAssetSubOptions , CloseSubOptions , PublishSubOptions , ExportSubOptions , InitSubOptions , ShowConfigSubOptions , LabelSubOptions > ( args )
39
39
. MapResult (
40
40
( CreateSubOptions opts ) => CreateReleaseAsync ( opts , fileSystem ) . Result ,
41
41
( AddAssetSubOptions opts ) => AddAssetsAsync ( opts ) . Result ,
@@ -44,6 +44,7 @@ private static int Main(string[] args)
44
44
( ExportSubOptions opts ) => ExportReleasesAsync ( opts , fileSystem ) . Result ,
45
45
( InitSubOptions opts ) => CreateSampleConfigFile ( opts , fileSystem ) ,
46
46
( ShowConfigSubOptions opts ) => ShowConfig ( opts , fileSystem ) ,
47
+ ( LabelSubOptions opts ) => CreateLabelsAsync ( opts ) . Result ,
47
48
errs => 1 ) ;
48
49
}
49
50
@@ -179,6 +180,46 @@ private static int ShowConfig(ShowConfigSubOptions subOptions, IFileSystem fileS
179
180
return 0 ;
180
181
}
181
182
183
+ private static async Task < int > CreateLabelsAsync ( LabelSubOptions subOptions )
184
+ {
185
+ try
186
+ {
187
+ ConfigureLogging ( subOptions . LogFilePath ) ;
188
+
189
+ var newLabels = new List < NewLabel > ( ) ;
190
+ newLabels . Add ( new NewLabel ( "Breaking change" , "b60205" ) ) ;
191
+ newLabels . Add ( new NewLabel ( "Bug" , "ee0701" ) ) ;
192
+ newLabels . Add ( new NewLabel ( "Build" , "009800" ) ) ;
193
+ newLabels . Add ( new NewLabel ( "Documentation" , "d4c5f9" ) ) ;
194
+ newLabels . Add ( new NewLabel ( "Feature" , "84b6eb" ) ) ;
195
+ newLabels . Add ( new NewLabel ( "Improvement" , "207de5" ) ) ;
196
+ newLabels . Add ( new NewLabel ( "Question" , "cc317c" ) ) ;
197
+ newLabels . Add ( new NewLabel ( "good first issue" , "7057ff" ) ) ;
198
+ newLabels . Add ( new NewLabel ( "help wanted" , "33aa3f" ) ) ;
199
+
200
+ var github = subOptions . CreateGitHubClient ( ) ;
201
+
202
+ var labels = await github . Issue . Labels . GetAllForRepository ( subOptions . RepositoryOwner , subOptions . RepositoryName ) ;
203
+
204
+ foreach ( var label in labels )
205
+ {
206
+ await github . Issue . Labels . Delete ( subOptions . RepositoryOwner , subOptions . RepositoryName , label . Name ) ;
207
+ }
208
+
209
+ foreach ( var label in newLabels )
210
+ {
211
+ await github . Issue . Labels . Create ( subOptions . RepositoryOwner , subOptions . RepositoryName , label ) ;
212
+ }
213
+
214
+ return 0 ;
215
+ }
216
+ catch ( Exception ex )
217
+ {
218
+ Console . WriteLine ( ex ) ;
219
+
220
+ return 1 ;
221
+ }
222
+ }
182
223
private static async Task < Release > CreateReleaseFromMilestone ( GitHubClient github , string owner , string repository , string milestone , string targetCommitish , IList < string > assets , bool prerelease , Config configuration )
183
224
{
184
225
var releaseNotesBuilder = new ReleaseNotesBuilder ( new DefaultGitHubClient ( github , owner , repository ) , owner , repository , milestone , configuration ) ;
0 commit comments