Bash WP-CLI - Generate a task list of all WP-CLI commands

<?php /** * Run with: wp eval-file cmd-list.php --skip-wordpress | pbcopy */ $ret = WP_CLI::launch_self( 'cli cmd-dump', array(), array( 'format' => 'json' ), true, true ); $cmds = json_decode( $ret->stdout, true ); $cmd_list = array(); foreach( $cmds['subcommands'] as $cmd ) { $cmd_list[] = $cmd['name']; if ( ! empty( $cmd['subcommands'] ) ) { foreach( $cmd['subcommands'] as $sub_cmd ) { $cmd_list[] = $cmd['name'] . ' ' . $sub_cmd['name']; if ( ! empty( $sub_cmd['subcommands'] ) ) { foreach( $sub_cmd['subcommands'] as $sub_sub_cmd ) { $cmd_list[] = $cmd['name'] . ' ' . $sub_cmd['name'] . ' ' . $sub_sub_cmd['name']; } } } } } foreach( $cmd_list as $cmd_str ) { $bits = explode( ' ', $cmd_str ); WP_CLI::log( '* [ ] ' . $cmd_str . ' ([current doc](http://wp-cli.org/commands/' . str_replace( ' ', '/', $cmd_str ) . '/), [file to edit](https://github.com/wp-cli/wp-cli/blob/master/php/commands/' . $bits[0] . '.php))' ); }

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.