1818use Mantle \Support \Str ;
1919use Mantle \Support \Traits \Conditionable ;
2020
21+ use function Mantle \Support \Helpers \collect ;
22+
2123/**
2224 * Boot Manager
2325 *
@@ -36,6 +38,16 @@ class Bootloader implements Contract {
3638 */
3739 protected static ?Bootloader $ instance ;
3840
41+ /**
42+ * The application instance.
43+ */
44+ protected string $ wp_cli_command_prefix = 'mantle ' ;
45+
46+ /**
47+ * The description of the WP-CLI command.
48+ */
49+ protected string $ wp_cli_command_description = '' ;
50+
3951 /**
4052 * Create a new instance of the application.
4153 *
@@ -95,7 +107,8 @@ public function __construct( protected ?Contracts\Application $app = null, ?stri
95107 $ this
96108 ->with_application ( $ app ?? new Application ( $ base_path ) )
97109 ->with_kernels ()
98- ->with_exception_handler ();
110+ ->with_exception_handler ()
111+ ->with_wp_cli_options ( Command::PREFIX , __ ( 'Mantle Framework Command Line Interface ' , 'mantle ' ) );
99112 }
100113
101114 /**
@@ -229,6 +242,24 @@ function ( Application $app ) use ( $callback, $web, $rest_api, $pass_through ):
229242 return $ this ;
230243 }
231244
245+ /**
246+ * Setup the WP-CLI command prefix and description.
247+ *
248+ * @param string|null $prefix Command prefix.
249+ * @param string|null $description Command description.
250+ */
251+ public function with_wp_cli_options ( ?string $ prefix = null , ?string $ description = null ): static {
252+ if ( $ prefix ) {
253+ $ this ->wp_cli_command_prefix = $ prefix ;
254+ }
255+
256+ if ( $ description ) {
257+ $ this ->wp_cli_command_description = $ description ;
258+ }
259+
260+ return $ this ;
261+ }
262+
232263 /**
233264 * Bind to the container before booting.
234265 *
@@ -315,13 +346,7 @@ protected function boot_console_wp_cli(): void {
315346 $ kernel ->bootstrap ();
316347
317348 \WP_CLI ::add_command (
318- /**
319- * Command prefix for Mantle WP-CLI commands.
320- *
321- * @param string $prefix The command prefix.
322- * @param \Mantle\Contracts\Application $app The application instance.
323- */
324- (string ) apply_filters ( 'mantle_console_command_prefix ' , Command::PREFIX , $ this ->app ),
349+ $ this ->wp_cli_command_prefix ,
325350 function () use ( $ kernel ): void {
326351 $ status = $ kernel ->handle (
327352 $ input = new \Symfony \Component \Console \Input \ArgvInput (
@@ -338,7 +363,7 @@ function () use ( $kernel ): void {
338363 exit ( (int ) $ status );
339364 },
340365 [
341- 'shortdesc ' => __ ( ' Mantle Framework Command Line Interface ' , ' mantle ' ) ,
366+ 'shortdesc ' => $ this -> wp_cli_command_description ,
342367 ]
343368 );
344369 }
0 commit comments