feat: implement graceful shutdown support with cancellation tokens #2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request improves cancellation support and error handling across several command implementations in the
docfxtool. The main changes ensure that long-running operations can be cancelled gracefully using aCancellationToken, and that the application returns appropriate exit codes and logs warnings when operations are cancelled.Enhanced cancellation support and error handling:
BuildCommand,DefaultCommand,MergeCommand,PdfCommand, andDownloadCommand) to accept and properly handleCancellationToken, ensuring operations can be cancelled cleanly and return the correct exit code (130) when cancelled. [1] [2] [3] [4] [5]CommandHelper.RunandCommandHelper.RunAsyncto catchOperationCanceledException, log a warning, and return exit code 130 if cancelled, instead of -1 or 0.Refactoring and consistency improvements:
DownloadCommandto be asynchronous, use proper logging, and support cancellation, improving consistency with other commands.These changes make the command-line experience more robust, especially when running long builds or downloads that may need to be interrupted.