From 01965d942797f8250a492e7c7191382ad1cf106f Mon Sep 17 00:00:00 2001
From: Alex Weber <alexweber15@gmail.com>
Date: Wed, 15 Feb 2012 16:27:44 -0200
Subject: [PATCH 1/4] #1272586

added descriptions for --version option in hook_drush_help()
---
 features.drush.inc |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/features.drush.inc b/features.drush.inc
index 24238dc..038db39 100644
--- a/features.drush.inc
+++ b/features.drush.inc
@@ -100,9 +100,9 @@ function features_drush_help($section) {
     case 'drush:features':
       return dt("List all the available features for your site.");
     case 'drush:features-export':
-      return dt("Export a feature from your site into a module. If called with no arguments, display a list of available components. If called with a single argument, attempt to create a feature including the given component with the same name. The option '--destination=foo' may be used to specify the path (from Drupal root) where the feature should be created. The default destination is 'sites/all/modules'.");
+      return dt("Export a feature from your site into a module. If called with no arguments, display a list of available components. If called with a single argument, attempt to create a feature including the given component with the same name. The option '--destination=foo' may be used to specify the path (from Drupal root) where the feature should be created. The default destination is 'sites/all/modules'. The option '--version=foo' may be used to specify a new version number for the feature.");
     case 'drush:features-update':
-      return dt("Update a feature module on your site.");
+      return dt("Update a feature module on your site. The option '--version=foo' may be used to specify a new version number for the feature.");
     case 'drush:features-update-all':
       return dt("Update all feature modules on your site.");
     case 'drush:features-revert':
@@ -114,7 +114,7 @@ function features_drush_help($section) {
     case 'drush:features-diff':
       return dt("Show a diff of a feature module.");
     case 'drush:features-add':
-      return dt("Add a component to a feature module.");
+      return dt("Add a component to a feature module. The option '--version=foo' may be used to specify a new version number for the feature.");
   }
 }
 
-- 
1.7.5.4


From e5a732ddb392c32e8d8459584186e0e0689ced20 Mon Sep 17 00:00:00 2001
From: Alex Weber <alexweber15@gmail.com>
Date: Wed, 15 Feb 2012 16:28:29 -0200
Subject: [PATCH 2/4] #1272586

added --version option to hook_drush_command(), affected commands are: features-add, features-export and features-update
---
 features.drush.inc |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/features.drush.inc b/features.drush.inc
index 038db39..a1237e0 100644
--- a/features.drush.inc
+++ b/features.drush.inc
@@ -29,6 +29,7 @@ function features_drush_command() {
     ),
     'options' => array(
       'destination' => "Destination path (from Drupal root) of the exported feature. Defaults to 'sites/all/modules'",
+      'version' => "Specify a new version number for the feature.'",
     ),
     'drupal dependencies' => array('features'),
     'aliases' => array('fe'),
@@ -40,6 +41,9 @@ function features_drush_command() {
       'feature' => 'Feature name to add to.',
       'components' => 'List of components to add.',
     ),
+    'options' => array(
+      'version' => "Specify a new version number for the feature.'",
+    ),
     'aliases' => array('fa'),
   );
   $items['features-update'] = array(
@@ -47,6 +51,9 @@ function features_drush_command() {
     'arguments' => array(
       'feature' => 'A space delimited list of features.',
     ),
+    'options' => array(
+      'version' => "Specify a new version number for the feature.'",
+    ),
     'drupal dependencies' => array('features'),
     'aliases' => array('fu'),
   );
-- 
1.7.5.4


From 0869b89d90f4aa30d37a23654eeb058cfff46eb5 Mon Sep 17 00:00:00 2001
From: Alex Weber <alexweber15@gmail.com>
Date: Wed, 15 Feb 2012 16:57:28 -0200
Subject: [PATCH 3/4] #1272586

Set feature version if option is passed
---
 features.drush.inc |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/features.drush.inc b/features.drush.inc
index a1237e0..8eb9a49 100644
--- a/features.drush.inc
+++ b/features.drush.inc
@@ -451,6 +451,10 @@ function _drush_features_export($stub, $dependencies, $module_name = NULL, $dire
       if (!feature_load($module_name)) {
         $export['name'] = $module_name;
       }
+      // Set the feature version if the --version option is passed.
+      if ($version = drush_get_option(array('version'))) {
+        $export['version'] = $version;
+      }
       $files = features_export_render($export, $module_name, TRUE);
       foreach ($files as $extension => $file_contents) {
         if (!in_array($extension, array('module', 'info'))) {
-- 
1.7.5.4


From bf06c6aeedb18ed7074b4e5d6a54c76e1df44809 Mon Sep 17 00:00:00 2001
From: Alex Weber <alexweber15@gmail.com>
Date: Wed, 15 Feb 2012 17:41:08 -0200
Subject: [PATCH 4/4] #1272586

added validation & die on error for --version option
---
 features.drush.inc |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/features.drush.inc b/features.drush.inc
index 8eb9a49..746ff69 100644
--- a/features.drush.inc
+++ b/features.drush.inc
@@ -453,6 +453,10 @@ function _drush_features_export($stub, $dependencies, $module_name = NULL, $dire
       }
       // Set the feature version if the --version option is passed.
       if ($version = drush_get_option(array('version'))) {
+        preg_match('/^(?P<core>\d+\.x)-(?P<major>\d+)\.(?P<patch>\d+)-?(?P<extra>\w+)?$/', $version, $matches);
+        if (!isset($matches['core'], $matches['major'])) {
+          drush_die(dt('Please enter a valid version with core and major version number. Example: !example', array('!example' => '7.x-1.0')));
+        }
         $export['version'] = $version;
       }
       $files = features_export_render($export, $module_name, TRUE);
-- 
1.7.5.4

