Permalink
Browse files

Added download command

  • Loading branch information...
1 parent ace1a7e commit 5ea2db73fbdcb037e17dcddfd5b76aa038e5e7b6 Zack Tollman committed Apr 15, 2012
Showing with 20 additions and 4 deletions.
  1. BIN WordPress Plugin Repo Search.alfredextension
  2. +1 −1 info.plist
  3. +19 −3 wp-plugin-search.php
Binary file not shown.
View
@@ -11,7 +11,7 @@
#Use: wpplugin <slug> <term> [num]
#Ex: wpplugin version debug bar
-#slug: key from the WordPress plugin repo response object. Valid args are: 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description'.
+#slug: key from the WordPress plugin repo response object. Valid args are: 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description', 'download'.
#term: search term to search against the WordPress plugin repo
#num: number of results to return. default = 1.
View
@@ -1,5 +1,5 @@
<?php
-$slugs = array( 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description' );
+$slugs = array( 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description', 'download' );
// Key 1 is the query send to the script from Alfred
$query = $argv[1];
@@ -56,10 +56,26 @@
// Print only the requested piece of information
foreach ( $results->plugins as $key => $plugin ) {
- echo $plugin->name . ' (' . $slug . ')' . ":\n";
+ if ( 'download' != $slug )
+ echo $plugin->name . ' (' . $slug . ')' . ":\n";
- if ( 'contributors' != $slug ) {
+ if ( 'contributors' != $slug && 'download' != $slug ) {
echo strip_tags( $plugin->$slug ) . $delimiter . $delimiter;
+ } elseif ( 'download' == $slug ) {
+ $filename = $plugin->slug . '.zip';
+ $file_location = 'http://downloads.wordpress.org/plugin/' . $filename;
+ $local_save = '~/Desktop/' . $filename;
+
+ // @todo: find a better way to test this
+ if ( '' == exec( 'curl ' . $file_location . ' -o ' . $local_save ) ) {
+ echo $plugin->name . ' downloaded to the desktop.' . "\n";
+
+ exec( 'cd ~/Desktop;unzip ' . $filename );
+ echo $filename . ' unzipped to the desktop.' . "\n";
+
+ if ( '' == exec( 'rm ~/Desktop/' . $filename ) )
+ echo $filename . ' removed.' . $delimiter . $delimiter;
+ }
} else {
if ( is_array( $plugin->$slug ) ) {
echo strip_tags( implode( ', ', array_keys( $plugin->$slug ) ) ) . $delimiter . $delimiter;

0 comments on commit 5ea2db7

Please sign in to comment.