File tree Expand file tree Collapse file tree 5 files changed +57
-5
lines changed
Expand file tree Collapse file tree 5 files changed +57
-5
lines changed Original file line number Diff line number Diff line change 11using Belin . PhpMinifier . Cli ;
22
33// Start the application.
4- return new RootCommand ( ) . Parse ( args ) . Invoke ( ) ;
4+ return await new RootCommand ( ) . Parse ( args ) . InvokeAsync ( ) ;
Original file line number Diff line number Diff line change @@ -11,15 +11,16 @@ internal class RootCommand: System.CommandLine.RootCommand {
1111 /// Creates a new root command.
1212 /// </summary>
1313 public RootCommand ( ) : base ( "Minify PHP source code by removing comments and whitespace." ) {
14- SetAction ( Invoke ) ;
14+ SetAction ( InvokeAsync ) ;
1515 }
1616
1717 /// <summary>
1818 /// Invokes this command.
1919 /// </summary>
2020 /// <param name="parseResult">The results of parsing the command line input.</param>
21+ /// <param name="cancellationToken">The token to cancel the operation.</param>
2122 /// <returns>The exit code.</returns>
22- public int Invoke ( ParseResult parseResult ) {
23- return 0 ;
23+ public Task < int > InvokeAsync ( ParseResult parseResult , CancellationToken cancellationToken ) {
24+ return Task . FromResult ( 0 ) ;
2425 }
2526}
Original file line number Diff line number Diff line change 1+ namespace Belin . PhpMinifier ;
2+
3+ /// <summary>
4+ /// Removes comments and whitespace from a PHP script, by calling a Web service.
5+ /// </summary>
6+ /// <param name="executable">The path to the PHP executable.</param>
7+ public sealed class FastTransformer ( string executable = "php" ) : ITransformer {
8+
9+ /// <summary>
10+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
11+ /// </summary>
12+ public ValueTask DisposeAsync ( ) {
13+ return ValueTask . CompletedTask ;
14+ }
15+
16+ /// <summary>
17+ /// Processes a PHP script.
18+ /// </summary>
19+ /// <param name="file">The path to the PHP script.</param>
20+ /// <returns>The transformed script.</returns>
21+ public Task < string > Transform ( string file ) {
22+ return Task . FromResult ( string . Empty ) ;
23+ }
24+ }
Original file line number Diff line number Diff line change @@ -10,5 +10,5 @@ public interface ITransformer: IAsyncDisposable {
1010 /// </summary>
1111 /// <param name="file">The path to the PHP script.</param>
1212 /// <returns>The transformed script.</returns>
13- string Transform ( string file ) ;
13+ Task < string > Transform ( string file ) ;
1414}
Original file line number Diff line number Diff line change 1+ namespace Belin . PhpMinifier ;
2+
3+ using System . Diagnostics ;
4+ using System . Threading . Tasks ;
5+
6+ /// <summary>
7+ /// Removes comments and whitespace from a PHP script, by calling a PHP process.
8+ /// </summary>
9+ /// <param name="executable">The path to the PHP executable.</param>
10+ public sealed class SafeTransformer ( string executable = "php" ) : ITransformer {
11+
12+ /// <summary>
13+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
14+ /// </summary>
15+ public ValueTask DisposeAsync ( ) => ValueTask . CompletedTask ;
16+
17+ /// <summary>
18+ /// Processes a PHP script.
19+ /// </summary>
20+ /// <param name="file">The path to the PHP script.</param>
21+ /// <returns>The transformed script.</returns>
22+ public async Task < string > Transform ( string file ) {
23+ var process = Process . Start ( executable ) ;
24+ await process . WaitForExitAsync ( ) ;
25+ return string . Empty ;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments