# install dependencies
- composer install --dev --no-interaction --prefer-source
- composer require d11wtq/boris=dev-master --no-interaction --prefer-source
+ - gem install ronn
# set up WP install
- bin/wp core download --version=$WP_VERSION --path=/tmp/wp-cli-test-core-download-cache/
# set up database
Scenario: Getting help for a third-party command
Given a WP install
- And a wp-content/plugins/test-cli-help.php file:
+ And a wp-content/plugins/test-cli/test-help.txt file:
+ """
+ ## EXAMPLES
+
+ wp test-help
+ """
+ And a wp-content/plugins/test-cli/command.php file:
"""
<?php
// Plugin Name: Test CLI Help
}
WP_CLI::add_command( 'test-help', 'Test_Help' );
+
+ WP_CLI::add_man_dir( __DIR__, __DIR__ );
"""
- And I run `wp plugin activate test-cli-help`
+ And I run `wp plugin activate test-cli`
When I run `wp help test-help`
Then STDOUT should contain:
usage: wp test-help
"""
- Scenario: Generating help
+ When I run `wp help --gen test-help`
+ Then STDOUT should contain:
+ """
+ generated test-help.1
+ """
+
+ When I run `wp help test-help`
+ Then STDOUT should contain:
+ """
+ WP-TEST-HELP(1)
+ """
+
+ Scenario: Generating help for multisite-only subcommands
Given an empty directory
When I run `wp help --gen blog create`
Then STDOUT should be:
$steps->Given( '/^a ([^\s]+) file:$/',
function ( $world, $path, PyStringNode $content ) {
$content = (string) $content . "\n";
- file_put_contents( $world->get_path( $path ), $content );
+ $full_path = $world->get_path( $path );
+ Process::create( \WP_CLI\utils\esc_cmd( 'mkdir -p %s', dirname( $full_path ) ) )->run_check();
+ file_put_contents( $full_path, $content );
}
);
*/
static function init() {
self::add_man_dir(
- WP_CLI_ROOT . "../man/",
- WP_CLI_ROOT . "../man-src/"
+ WP_CLI_ROOT . "../man",
+ WP_CLI_ROOT . "../man-src"
);
self::$root = new Dispatcher\RootCommand;
$command = WP_CLI\Utils\find_subcommand( $args );
- if ( !$command ) {
- WP_CLI::error( sprintf( "'%s' command not found.",
- implode( ' ', $arg_copy ) ) );
+ if ( $command ) {
+ foreach ( WP_CLI::get_man_dirs() as $dest_dir => $src_dir ) {
+ WP_CLI\Man\generate( $src_dir, $dest_dir, $command );
+ }
+ exit;
}
- foreach ( WP_CLI::get_man_dirs() as $dest_dir => $src_dir ) {
- WP_CLI\Man\generate( $src_dir, $dest_dir, $command );
+ // WordPress is already loaded, so there's no chance we'll find the command
+ if ( function_exists( 'add_filter' ) ) {
+ WP_CLI::error( sprintf( "'%s' command not found.", implode( ' ', $arg_copy ) ) );
}
-
- exit;
}
}
$cmd_path = Dispatcher\get_path( $command );
array_shift( $cmd_path ); // discard 'wp'
- $src_path = $src_dir . get_src_file_name( $cmd_path );
- $dest_path = $dest_dir . get_file_name( $cmd_path );
+ $src_path = "$src_dir/" . get_src_file_name( $cmd_path );
+ $dest_path = "$dest_dir/" . get_file_name( $cmd_path );
call_ronn( get_markdown( $src_path, $command ), $dest_path );
$man_file = get_file_name( $args );
foreach ( \WP_CLI::get_man_dirs() as $dest_dir => $_ ) {
- $man_path = $dest_dir . $man_file;
+ $man_path = "$dest_dir/" . $man_file;
if ( is_readable( $man_path ) ) {
show_manpage( $man_path );