Skip to content

Commit

Permalink
Plugin Directory: Bin: Allow passing a download URL to the rebuild-zi…
Browse files Browse the repository at this point in the history
…ps command for ease of use.

git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14090 74240141-8908-4e6f-9713-ba540dce6ec7
  • Loading branch information
dd32 committed Oct 3, 2024
1 parent 1410369 commit 272e831
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,17 @@

// Guess the default parameters:
if ( empty( $opts ) && $argc == 2 ) {
$opts['plugin'] = $argv[1];
$argv[1] = '--plugin ' . $argv[1];
if ( preg_match( '#^https?://downloads.w(ordpress)?.org/plugin/(?P<slug>[a-z0-9-]+)(\.(?P<version>.+))?\.zip$#', $argv[1], $m ) ) {

$opts['plugin'] = $m['slug'];
$argv[1] = '--plugin ' . $m['slug'];

$opts['versions'] = $m['version'] ?: 'trunk';
$argv[2] = '--versions ' . $opts['versions'];
} else {
$opts['plugin'] = $argv[1];
$argv[1] = '--plugin ' . $argv[1];
}
}
if ( empty( $opts ) && $argc == 3 ) {
$opts['plugin'] = $argv[1];
Expand All @@ -39,7 +48,10 @@
foreach ( array( 'url', 'abspath', 'plugin' ) as $opt ) {
if ( empty( $opts[ $opt ] ) ) {
fwrite( STDERR, "Missing Parameter: $opt\n" );
fwrite( STDERR, "Usage: php {$argv[0]} --plugin hello-dolly --versions 1.0,trunk --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" );
fwrite( STDERR, "Usage: \n" );
fwrite( STDERR, "\tphp {$argv[0]} --plugin hello-dolly --versions 1.0,trunk\n" );
fwrite( STDERR, "\tphp {$argv[0]} https://downloads.wordpress.org/plugin/hello-dolly.1.0.zip\n" );
fwrite( STDERR, "\tphp {$argv[0]} --plugin hello-dolly --versions 1.0,trunk --abspath /home/example/public_html --url https://wordpress.org/plugins/\n" );
fwrite( STDERR, "--url and --abspath will be guessed if possible.\n" );
fwrite( STDERR, "--versions if skipped will rebuild all tags/trunk.\n" );
exit( 1 );
Expand Down

0 comments on commit 272e831

Please sign in to comment.