@@ -18,96 +18,96 @@ public static class Program
1818
1919 public static async Task Main ( string [ ] args )
2020 {
21- RootCommand rootCommand = new ( "genapidiff " ) ;
21+ RootCommand rootCommand = new ( "ApiDiff - Tool for generating a markdown diff of two different versions of the same assembly. " ) ;
2222
23- Option < string > optionBeforeAssembliesFolderPath = new ( name : "" , aliases : [ " --before", "-b" ] )
23+ Option < string > optionBeforeAssembliesFolderPath = new ( " --before", "-b" )
2424 {
2525 Description = "The path to the folder containing the old (before) assemblies to be included in the diff." ,
2626 Arity = ArgumentArity . ExactlyOne ,
2727 Required = true
2828 } ;
2929
30- Option < string > optionBeforeRefAssembliesFolderPath = new ( name : "" , aliases : [ " --refbefore", "-rb" ] )
30+ Option < string > optionBeforeRefAssembliesFolderPath = new ( " --refbefore", "-rb" )
3131 {
3232 Description = "The path to the folder containing the references required by old (before) assemblies, not to be included in the diff." ,
3333 Arity = ArgumentArity . ExactlyOne ,
3434 Required = false
3535 } ;
3636
37- Option < string > optionAfterAssembliesFolderPath = new ( name : "" , aliases : [ " --after", "-a" ] )
37+ Option < string > optionAfterAssembliesFolderPath = new ( " --after", "-a" )
3838 {
3939 Description = "The path to the folder containing the new (after) assemblies to be included in the diff." ,
4040 Arity = ArgumentArity . ExactlyOne ,
4141 Required = true
4242 } ;
4343
44- Option < string > optionAfterRefAssembliesFolderPath = new ( name : "" , aliases : [ " --refafter", "-ra" ] )
44+ Option < string > optionAfterRefAssembliesFolderPath = new ( " --refafter", "-ra" )
4545 {
4646 Description = "The path to the folder containing references required by the new (after) reference assemblies, not to be included in the diff." ,
4747 Arity = ArgumentArity . ExactlyOne ,
4848 Required = false
4949 } ;
5050
51- Option < string > optionOutputFolderPath = new ( name : "" , aliases : [ " --output", "-o" ] )
51+ Option < string > optionOutputFolderPath = new ( " --output", "-o" )
5252 {
5353 Description = "The path to the output folder." ,
5454 Arity = ArgumentArity . ExactlyOne ,
5555 Required = true
5656 } ;
5757
58- Option < string > optionBeforeFriendlyName = new ( name : "" , aliases : [ " --beforeFriendlyName", "-bfn" ] )
58+ Option < string > optionBeforeFriendlyName = new ( " --beforeFriendlyName", "-bfn" )
5959 {
6060 Description = "The friendly name to describe the 'before' assembly." ,
6161 Arity = ArgumentArity . ExactlyOne ,
6262 Required = true
6363 } ;
6464
65- Option < string > optionAfterFriendlyName = new ( name : "" , aliases : [ " --afterFriendlyName", "-afn" ] )
65+ Option < string > optionAfterFriendlyName = new ( " --afterFriendlyName", "-afn" )
6666 {
6767 Description = "The friendly name to describe the 'after' assembly." ,
6868 Arity = ArgumentArity . ExactlyOne ,
6969 Required = true
7070 } ;
7171
72- Option < string > optionTableOfContentsTitle = new ( name : "" , aliases : [ " --tableOfContentsTitle", "-tc" ] )
72+ Option < string > optionTableOfContentsTitle = new ( " --tableOfContentsTitle", "-tc" )
7373 {
7474 Description = $ "The optional title of the markdown table of contents file that is placed in the output folder.",
75- Arity = ArgumentArity . ZeroOrMore ,
75+ Arity = ArgumentArity . ExactlyOne ,
7676 Required = false ,
7777 DefaultValueFactory = _ => "api_diff"
7878 } ;
7979
80- Option < FileInfo [ ] ? > optionFilesWithAssembliesToExclude = new ( name : "" , aliases : [ " --assembliesToExclude", "-eas" ] )
80+ Option < FileInfo [ ] ? > optionFilesWithAssembliesToExclude = new ( " --assembliesToExclude", "-eas" )
8181 {
8282 Description = "An optional array of filepaths, each containing a list of assemblies that should be excluded from the diff. Each file should contain one assembly name per line, with no extensions." ,
8383 Arity = ArgumentArity . ZeroOrMore ,
8484 Required = false ,
8585 DefaultValueFactory = _ => null
8686 } ;
8787
88- Option < FileInfo [ ] ? > optionFilesWithAttributesToExclude = new ( name : "" , aliases : [ " --attributesToExclude", "-eattrs" ] )
88+ Option < FileInfo [ ] ? > optionFilesWithAttributesToExclude = new ( " --attributesToExclude", "-eattrs" )
8989 {
9090 Description = $ "An optional array of filepaths, each containing a list of attributes to exclude from the diff. Each file should contain one API full name per line. You can either modify the default file '{ AttributesToExcludeDefaultFileName } ' to add your own attributes, or include additional files using this command line option.",
9191 Arity = ArgumentArity . ZeroOrMore ,
9292 Required = false ,
9393 DefaultValueFactory = _ => [ new FileInfo ( AttributesToExcludeDefaultFileName ) ]
9494 } ;
9595
96- Option < FileInfo [ ] ? > optionFilesWithApisToExclude = new ( name : "" , aliases : [ " --apisToExclude", "-eapis" ] )
96+ Option < FileInfo [ ] ? > optionFilesWithApisToExclude = new ( " --apisToExclude", "-eapis" )
9797 {
9898 Description = "An optional array of filepaths, each containing a list of APIs to exclude from the diff. Each file should contain one API full name per line." ,
9999 Arity = ArgumentArity . ZeroOrMore ,
100100 Required = false ,
101101 DefaultValueFactory = _ => null
102102 } ;
103103
104- Option < bool > optionAddPartialModifier = new ( name : "" , aliases : [ " --addPartialModifier", "-apm" ] )
104+ Option < bool > optionAddPartialModifier = new ( " --addPartialModifier", "-apm" )
105105 {
106106 Description = "Add the 'partial' modifier to types." ,
107107 DefaultValueFactory = _ => false
108108 } ;
109109
110- Option < bool > optionAttachDebugger = new ( name : "" , aliases : [ " --attachDebugger", "-d" ] )
110+ Option < bool > optionAttachDebugger = new ( " --attachDebugger", "-d" )
111111 {
112112 Description = "Stops the tool at startup, prints the process ID and waits for a debugger to attach." ,
113113 DefaultValueFactory = _ => false
@@ -128,9 +128,9 @@ public static async Task Main(string[] args)
128128 rootCommand . Options . Add ( optionAddPartialModifier ) ;
129129 rootCommand . Options . Add ( optionAttachDebugger ) ;
130130
131- rootCommand . SetAction ( async ( ParseResult result ) =>
131+ rootCommand . SetAction ( async ( ParseResult result , CancellationToken cancellationToken ) =>
132132 {
133- DiffConfiguration c = new (
133+ DiffConfiguration diffConfig = new (
134134 BeforeAssembliesFolderPath : result . GetValue ( optionBeforeAssembliesFolderPath ) ?? throw new NullReferenceException ( "Null before assemblies directory" ) ,
135135 BeforeAssemblyReferencesFolderPath : result . GetValue ( optionBeforeRefAssembliesFolderPath ) ,
136136 AfterAssembliesFolderPath : result . GetValue ( optionAfterAssembliesFolderPath ) ?? throw new NullReferenceException ( "Null after assemblies directory" ) ,
@@ -145,13 +145,15 @@ public static async Task Main(string[] args)
145145 AddPartialModifier : result . GetValue ( optionAddPartialModifier ) ,
146146 AttachDebugger : result . GetValue ( optionAttachDebugger )
147147 ) ;
148- await HandleCommandAsync ( c ) . ConfigureAwait ( false ) ;
148+ await HandleCommandAsync ( diffConfig , cancellationToken ) . ConfigureAwait ( false ) ;
149149 } ) ;
150150 await rootCommand . Parse ( args ) . InvokeAsync ( ) ;
151151 }
152152
153- private static Task HandleCommandAsync ( DiffConfiguration diffConfig )
153+ private static Task HandleCommandAsync ( DiffConfiguration diffConfig , CancellationToken cancellationToken = default )
154154 {
155+ cancellationToken . ThrowIfCancellationRequested ( ) ;
156+
155157 var log = new ConsoleLog ( MessageImportance . Normal ) ;
156158
157159 string assembliesToExclude = string . Join ( ", " , diffConfig . FilesWithAssembliesToExclude ? . Select ( a => a . FullName ) ?? [ ] ) ;
@@ -197,7 +199,7 @@ private static Task HandleCommandAsync(DiffConfiguration diffConfig)
197199 diagnosticOptions : null // TODO: If needed, add CLI option to pass specific diagnostic options
198200 ) ;
199201
200- return diffGenerator . RunAsync ( ) ;
202+ return diffGenerator . RunAsync ( cancellationToken ) ;
201203 }
202204
203205 private static void WaitForDebugger ( )
0 commit comments