ソースを参照

Added the Zend\Service\Console

Enrico Zimuel 11 年 前
コミット
2a701e0360

+ 422 - 0
library/Zend/Service/Console/Command.php

@@ -0,0 +1,422 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command
+{
+	/**
+	 * The handler.
+	 *
+	 * @var array
+	 */
+	protected $_handler;
+
+	/**
+	 * Gets the handler.
+	 *
+	 * @return array
+	 */
+	public function getHandler()
+	{
+		return $this->_handler;
+	}
+
+	/**
+	 * Sets the handler.
+	 *
+	 * @param array $handler
+	 * @return Zend_Service_Console_Command
+	 */
+	public function setHandler($handler)
+	{
+		$this->_handler = $handler;
+		return $this;
+	}
+
+	/**
+	 * Replaces PHP's error handler
+	 *
+	 * @param mixed $errno
+	 * @param mixed $errstr
+	 * @param mixed $errfile
+	 * @param mixed $errline
+	 */
+	public static function phpstderr($errno, $errstr, $errfile, $errline)
+	{
+		self::stderr($errno . ': Error in ' . $errfile . ':' . $errline . ' - ' . $errstr);
+	}
+
+	/**
+	 * Replaces PHP's exception handler
+	 *
+	 * @param Exception $exception
+	 */
+	public static function phpstdex($exception)
+	{
+		self::stderr('Error: ' . $exception->getMessage());
+	}
+
+	/**
+	 * Writes output to STDERR, followed by a newline (optional)
+	 *
+	 * @param string $errorMessage
+	 * @param string $newLine
+	 */
+	public static function stderr($errorMessage, $newLine = true)
+	{
+		if (error_reporting() === 0) {
+			return;
+		}
+		file_put_contents('php://stderr', $errorMessage . ($newLine ? "\r\n" : ''));
+	}
+
+	/**
+	 * Bootstrap the shell command.
+	 *
+	 * @param array $argv PHP argument values.
+	 */
+	public static function bootstrap($argv)
+	{
+		// Abort bootstrapping depending on the MICROSOFT_CONSOLE_COMMAND_HOST constant.
+		if (defined('MICROSOFT_CONSOLE_COMMAND_HOST') && strtolower(MICROSOFT_CONSOLE_COMMAND_HOST) != 'console') {
+			return;
+		}
+
+		// Replace error handler
+		set_error_handler(array('Zend_Service_Console_Command', 'phpstderr'));
+		set_exception_handler(array('Zend_Service_Console_Command', 'phpstdex'));
+
+		// Build the application model
+		$model = self::_buildModel();
+
+		// Find a class that corresponds to the $argv[0] script name
+		$requiredHandlerName = str_replace('.bat', '', str_replace('.sh', '', str_replace('.php', '', strtolower(basename($argv[0])))));
+		$handler = null;
+		foreach ($model as $possibleHandler) {
+			if ($possibleHandler->handler == strtolower($requiredHandlerName)) {
+				$handler = $possibleHandler;
+				break;
+			}
+		}
+		if (is_null($handler)) {
+			self::stderr("No class found that implements handler '" . $requiredHandlerName . "'. Create a class that is named '" . $requiredHandlerName . "' and extends Zend_Service_Console_Command or is decorated with a docblock comment '@command-handler " . $requiredHandlerName . "'. Make sure it is loaded either through an autoloader or explicitly using require_once().");
+			die();
+		}
+
+		// Find a method that matches the command name
+		$command = null;
+		foreach ($handler->commands as $possibleCommand) {
+			if (in_array(strtolower(isset($argv[1]) ? $argv[1] : '<default>'), $possibleCommand->aliases)) {
+				$command = $possibleCommand;
+				break;
+			}
+		}
+		if (is_null($command)) {
+			$commandName = (isset($argv[1]) ? $argv[1] : '<default>');
+			self::stderr("No method found that implements command " . $commandName . ". Create a method in class '" . $handler->class . "' that is named '" . strtolower($commandName) . "Command' or is decorated with a docblock comment '@command-name " . $commandName . "'.");
+			die();
+		}
+
+		// Parse parameter values
+		$parameterValues = array();
+		$missingParameterValues = array();
+		$parameterInputs = array_splice($argv, 2);
+		foreach ($command->parameters as $parameter) {
+			// Default value: null
+			$value = null;
+
+			// Consult value providers for value. First one wins.
+			foreach ($parameter->valueproviders as $valueProviderName) {
+				if (!class_exists($valueProviderName)) {
+					$valueProviderName = 'Zend_Service_Console_Command_ParameterSource_' . $valueProviderName;
+				}
+				$valueProvider = new $valueProviderName();
+
+				$value = $valueProvider->getValueForParameter($parameter, $parameterInputs);
+				if (!is_null($value)) {
+					break;
+				}
+			}
+			if (is_null($value) && $parameter->required) {
+				$missingParameterValues[] = $parameter->aliases[0];
+			} else if (is_null($value)) {
+				$value = $parameter->defaultvalue;
+			}
+
+			// Set value
+			$parameterValues[] = $value;
+			$argvValues[$parameter->aliases[0]] = $value;
+		}
+
+		// Mising parameters?
+		if (count($missingParameterValues) > 0) {
+			self::stderr("Some parameters are missing:\r\n" . implode("\r\n", $missingParameterValues));
+			die();
+		}
+
+		// Supply argv in a nice way
+		$parameterValues['argv'] = $parameterInputs;
+
+		// Run the command
+		$className = $handler->class;
+		$classInstance = new $className();
+		$classInstance->setHandler($handler);
+		call_user_func_array(array($classInstance, $command->method), $parameterValues);
+
+		// Restore error handler
+		restore_exception_handler();
+		restore_error_handler();
+	}
+
+	/**
+	 * Builds the handler model.
+	 *
+	 * @return array
+	 */
+	protected static function _buildModel()
+	{
+		$model = array();
+
+		$classes = get_declared_classes();
+		foreach ($classes as $class) {
+			$type = new ReflectionClass($class);
+
+			$handlers = self::_findValueForDocComment('@command-handler', $type->getDocComment());
+			if (count($handlers) == 0 && $type->isSubclassOf('Zend_Service_Console_Command')) {
+				// Fallback: if the class extends Zend_Service_Console_Command, register it as
+				// a command handler.
+				$handlers[] = $class;
+			}
+			$handlerDescriptions = self::_findValueForDocComment('@command-handler-description', $type->getDocComment());
+			$handlerHeaders = self::_findValueForDocComment('@command-handler-header', $type->getDocComment());
+			$handlerFooters = self::_findValueForDocComment('@command-handler-footer', $type->getDocComment());
+
+			for ($hi = 0; $hi < count($handlers); $hi++) {
+				$handler = $handlers[$hi];
+				$handlerDescription = isset($handlerDescriptions[$hi]) ? $handlerDescriptions[$hi] : isset($handlerDescriptions[0]) ? $handlerDescriptions[0] : '';
+				$handlerDescription = str_replace('\r\n', "\r\n", $handlerDescription);
+				$handlerDescription = str_replace('\n', "\n", $handlerDescription);
+
+				$handlerModel = (object)array(
+					'handler'     => strtolower($handler),
+					'description' => $handlerDescription,
+					'headers'     => $handlerHeaders,
+					'footers'     => $handlerFooters,
+					'class'       => $class,
+					'commands'    => array()
+				);
+
+				$methods = $type->getMethods();
+			    foreach ($methods as $method) {
+			       	$commands = self::_findValueForDocComment('@command-name', $method->getDocComment());
+			    	if (substr($method->getName(), -7) == 'Command' && !in_array(substr($method->getName(), 0, -7), $commands)) {
+						// Fallback: if the method is named <commandname>Command,
+						// register it as a command.
+						$commands[] = substr($method->getName(), 0, -7);
+					}
+			       	for ($x = 0; $x < count($commands); $x++) {
+			       		$commands[$x] = strtolower($commands[$x]);
+			       	}
+			       	$commands = array_unique($commands);
+			       	$commandDescriptions = self::_findValueForDocComment('@command-description', $method->getDocComment());
+			       	$commandExamples = self::_findValueForDocComment('@command-example', $method->getDocComment());
+
+			       	if (count($commands) > 0) {
+						$command = $commands[0];
+						$commandDescription = isset($commandDescriptions[0]) ? $commandDescriptions[0] : '';
+
+						$commandModel = (object)array(
+							'command'     => $command,
+							'aliases'     => $commands,
+							'description' => $commandDescription,
+							'examples'    => $commandExamples,
+							'class'       => $class,
+							'method'      => $method->getName(),
+							'parameters'  => array()
+						);
+
+						$parameters = $method->getParameters();
+						$parametersFor = self::_findValueForDocComment('@command-parameter-for', $method->getDocComment());
+						for ($pi = 0; $pi < count($parameters); $pi++) {
+							// Initialize
+							$parameter = $parameters[$pi];
+							$parameterFor = null;
+							$parameterForDefaultValue = null;
+
+							// Is it a "catch-all" parameter?
+							if ($parameter->getName() == 'argv') {
+								continue;
+							}
+
+							// Find the $parametersFor with the same name defined
+							foreach ($parametersFor as $possibleParameterFor) {
+								$possibleParameterFor = explode(' ', $possibleParameterFor, 4);
+								if ($possibleParameterFor[0] == '$' . $parameter->getName()) {
+									$parameterFor = $possibleParameterFor;
+									break;
+								}
+							}
+							if (is_null($parameterFor)) {
+								die('@command-parameter-for missing for parameter $' . $parameter->getName());
+							}
+
+							if (is_null($parameterForDefaultValue) && $parameter->isOptional()) {
+								$parameterForDefaultValue = $parameter->getDefaultValue();
+							}
+
+							$parameterModel = (object)array(
+								'name'           => '$' . $parameter->getName(),
+								'defaultvalue'   => $parameterForDefaultValue,
+								'valueproviders' => explode('|', $parameterFor[1]),
+								'aliases'        => explode('|', $parameterFor[2]),
+								'description'    => (isset($parameterFor[3]) ? $parameterFor[3] : ''),
+								'required'       => (isset($parameterFor[3]) ? strpos(strtolower($parameterFor[3]), 'required') !== false && strpos(strtolower($parameterFor[3]), 'required if') === false : false),
+							);
+
+							// Add to model
+							$commandModel->parameters[] = $parameterModel;
+						}
+
+						// Add to model
+						$handlerModel->commands[] = $commandModel;
+			       	}
+				}
+
+				// Add to model
+				$model[] = $handlerModel;
+			}
+		}
+
+		return $model;
+	}
+
+	/**
+	 * Finds the value for a specific docComment.
+	 *
+	 * @param string $docCommentName Comment name
+	 * @param unknown_type $docComment Comment object
+	 * @return array
+	 */
+	protected static function _findValueForDocComment($docCommentName, $docComment)
+	{
+		$returnValue = array();
+
+		$commentLines = explode("\n", $docComment);
+	    foreach ($commentLines as $commentLine) {
+	        if (strpos($commentLine, $docCommentName . ' ') !== false) {
+	            $returnValue[] = trim(substr($commentLine, strpos($commentLine, $docCommentName) + strlen($docCommentName) + 1));
+	        }
+	    }
+
+	    return $returnValue;
+	}
+
+	/**
+	 * Display information on an object
+	 *
+	 * @param object $object Object
+	 * @param array $propertiesToDump Property names to display
+	 */
+	protected function _displayObjectInformation($object, $propertiesToDump = array())
+	{
+		foreach ($propertiesToDump as $property) {
+			printf('%-16s: %s' . "\r\n", $property, $object->$property);
+		}
+		printf("\r\n");
+	}
+
+	/**
+	 * Displays the help information.
+	 *
+	 * @command-name <default>
+	 * @command-name -h
+	 * @command-name -help
+	 * @command-description Displays the current help information.
+	 */
+	public function helpCommand() {
+		$handler = $this->getHandler();
+		$newline = "\r\n";
+
+		if (count($handler->headers) > 0) {
+			foreach ($handler->headers as $header) {
+				printf('%s%s', $header, $newline);
+			}
+			printf($newline);
+		}
+		printf('%s%s', $handler->description, $newline);
+		printf($newline);
+		printf('Available commands:%s', $newline);
+		foreach ($handler->commands as $command) {
+			$description = str_split($command->description, 50);
+			printf('  %-25s %s%s', implode(', ', $command->aliases), $description[0], $newline);
+			for ($di = 1; $di < count($description); $di++) {
+				printf('  %-25s %s%s', '', $description[$di], $newline);
+			}
+			printf($newline);
+
+			if (count($command->parameters) > 0) {
+				foreach ($command->parameters as $parameter) {
+					$description = str_split($parameter->description, 50);
+					printf('    %-23s %s%s', implode(', ', $parameter->aliases), $description[0], $newline);
+					for ($di = 1; $di < count($description); $di++) {
+						printf('    %-23s %s%s', '', $description[$di], $newline);
+					}
+					printf($newline);
+				}
+			}
+			printf($newline);
+
+			if (count($command->examples) > 0) {
+				printf('    Example usage:%s', $newline);
+				foreach ($command->examples as $example) {
+					printf('      %s%s', $example, $newline);
+				}
+				printf($newline);
+			}
+		}
+
+		if (count($handler->footers) > 0) {
+			printf($newline);
+			foreach ($handler->footers as $footer) {
+				printf('%s%s', $footer, $newline);
+			}
+			printf($newline);
+		}
+	}
+}

+ 80 - 0
library/Zend/Service/Console/Command/ParameterSource/Argv.php

@@ -0,0 +1,80 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+ * @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+ */
+require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command_ParameterSource_Argv
+	implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array())
+	{
+		// Default value
+		$parameterValue = null;
+
+		// Loop parameter inputs
+		foreach ($argv as $parameterInput) {
+			$parameterInput = explode('=', $parameterInput, 2);
+
+			if (in_array($parameterInput[0], $parameter->aliases)) {
+				$parameterValue = isset($parameterInput[1]) ? $parameterInput[1] : true;
+				break;
+			}
+		}
+		if (strtolower($parameterValue) == 'true') {
+			$parameterValue = true;
+		} else if (strtolower($parameterValue) == 'false') {
+			$parameterValue = false;
+		}
+
+		// Done!
+		return $parameterValue;
+	}
+}

+ 113 - 0
library/Zend/Service/Console/Command/ParameterSource/ConfigFile.php

@@ -0,0 +1,113 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+* @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+*/
+require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command_ParameterSource_ConfigFile
+	implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array())
+	{
+		// Configuration file path
+		$configurationFilePath = null;
+
+		// Check if a path to a configuration file is specified
+		foreach ($argv as $parameterInput) {
+			$parameterInput = explode('=', $parameterInput, 2);
+
+			if (strtolower($parameterInput[0]) == '--configfile' || strtolower($parameterInput[0]) == '-f') {
+				if (!isset($parameterInput[1])) {
+					require_once 'Zend/Service/Console/Exception.php';
+					throw new Zend_Service_Console_Exception("No path to a configuration file is given. Specify the path using the --ConfigFile or -F switch.");
+				}
+				$configurationFilePath = $parameterInput[1];
+				break;
+			}
+		}
+
+		// Value given?
+		if (is_null($configurationFilePath)) {
+			return null;
+		}
+		if (!file_exists($configurationFilePath)) {
+			require_once 'Zend/Service/Console/Exception.php';
+			throw new Zend_Service_Console_Exception("Invalid configuration file given. Specify the correct path using the --ConfigFile or -F switch.");
+		}
+
+		// Parse values
+		$iniValues = parse_ini_file($configurationFilePath);
+
+		// Default value
+		$parameterValue = null;
+
+		// Loop aliases
+		foreach ($parameter->aliases as $alias) {
+			if (array_key_exists($alias, $iniValues)) {
+				$parameterValue = $iniValues[$alias]; break;
+			} else if (array_key_exists(strtolower($alias), $iniValues)) {
+				$parameterValue = $iniValues[strtolower($alias)]; break;
+			} else if (array_key_exists(str_replace('-', '', $alias), $iniValues)) {
+				$parameterValue = $iniValues[str_replace('-', '', $alias)]; break;
+			} else if (array_key_exists(strtolower(str_replace('-', '', $alias)), $iniValues)) {
+				$parameterValue = $iniValues[strtolower(str_replace('-', '', $alias))]; break;
+			}
+		}
+
+		if (strtolower($parameterValue) == 'true') {
+			$parameterValue = true;
+		} else if (strtolower($parameterValue) == 'false') {
+			$parameterValue = false;
+		}
+
+		// Done!
+		return $parameterValue;
+	}
+}

+ 84 - 0
library/Zend/Service/Console/Command/ParameterSource/Env.php

@@ -0,0 +1,84 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+* @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+*/
+require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command_ParameterSource_Env
+	implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array())
+	{
+		// Default value
+		$parameterValue = null;
+
+		// Fetch value for parameter
+		foreach ($parameter->aliases as $alias) {
+			while (strpos($alias, '-') !== false) {
+				$alias = substr($alias, 1);
+			}
+			$value = getenv($alias);
+
+			if (!is_null($value) && $value !== false) {
+				$parameterValue = $value;
+				break;
+			}
+		}
+
+		if (strtolower($parameterValue) == 'true') {
+			$parameterValue = true;
+		} else if (strtolower($parameterValue) == 'false') {
+			$parameterValue = false;
+		}
+
+		// Done!
+		return $parameterValue;
+	}
+}

+ 52 - 0
library/Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php

@@ -0,0 +1,52 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+interface Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array());
+}

+ 75 - 0
library/Zend/Service/Console/Command/ParameterSource/Prompt.php

@@ -0,0 +1,75 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+* @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+*/
+require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command_ParameterSource_Prompt
+	implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array())
+	{
+		// Default value
+		$parameterValue = null;
+
+		// Prompt the user
+		fwrite(STDOUT, "Supply a value for " . $parameter->aliases[0] . ": ");
+		/*if ($parameter->description != '' && !is_null($parameter->description)) {
+			fwrite(STDOUT, $parameter->description . ".\r\n");
+		}*/
+
+		while (is_null($parameterValue) || $parameterValue == '') {
+			$parameterValue = trim(fgets(STDIN));
+		}
+
+		// Done!
+		return $parameterValue;
+	}
+}

+ 90 - 0
library/Zend/Service/Console/Command/ParameterSource/StdIn.php

@@ -0,0 +1,90 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+* @see Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+*/
+require_once 'Zend/Service/Console/Command/ParameterSource/ParameterSourceInterface.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Command_ParameterSource_StdIn
+	implements Zend_Service_Console_Command_ParameterSource_ParameterSourceInterface
+{
+	/**
+	 * Get value for a named parameter.
+	 *
+	 * @param mixed $parameter Parameter to get a value for
+	 * @param array $argv Argument values passed to the script when run in console.
+	 * @return mixed
+	 */
+	public function getValueForParameter($parameter, $argv = array())
+	{
+		// Default value
+		$parameterValue = null;
+
+		// Check STDIN for data
+		if (ftell(STDIN) !== false) {
+			// Read from STDIN
+			$fs = fopen("php://stdin", "r");
+			if ($fs !== false) {
+				/*
+				while (!feof($fs)) {
+					$data = fread($fs, 1);
+					var_dump($data);
+					$parameterValue .= $data;
+				} */
+				$parameterValue = stream_get_contents($fs);
+				fclose($fs);
+			}
+
+			// Remove ending \r\n
+			$parameterValue = rtrim($parameterValue);
+
+			if (strtolower($parameterValue) == 'true') {
+				$parameterValue = true;
+			} else if (strtolower($parameterValue) == 'false') {
+				$parameterValue = false;
+			}
+		}
+
+		// Done!
+		return $parameterValue;
+	}
+}

+ 48 - 0
library/Zend/Service/Console/Exception.php

@@ -0,0 +1,48 @@
+<?php
+/**
+ * Copyright (c) 2009 - 2011, RealDolmen
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copyright
+ *       notice, this list of conditions and the following disclaimer in the
+ *       documentation and/or other materials provided with the distribution.
+ *     * Neither the name of RealDolmen nor the
+ *       names of its contributors may be used to endorse or promote products
+ *       derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY RealDolmen ''AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL RealDolmen BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @subpackage Exception
+ * @version    $Id$
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+
+/**
+ * Zend_Service_Exception
+ */
+require_once 'Zend/Service/Exception.php';
+
+/**
+ * @category   Zend
+ * @package    Zend_Service_Console
+ * @copyright  Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
+ * @license    http://phpazure.codeplex.com/license
+ */
+class Zend_Service_Console_Exception extends Zend_Service_Exception
+{}

+ 24 - 14
library/Zend/Service/WindowsAzure/CommandLine/Certificate.php

@@ -20,24 +20,34 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
+/**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
+
+
+/**
+ * @see Zend_Service_WindowsAzure_Management_Client
+ */
+require_once 'Zend/Service/WindowsAzure/Management/Client.php';
 
 /**
  * Certificate commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler certificate
  * @command-handler-description Windows Azure Certificate commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer Note: Parameters that are common across all commands can be stored 
+ * @command-handler-footer Note: Parameters that are common across all commands can be stored
  * @command-handler-footer in two dedicated environment variables.
  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -45,10 +55,10 @@
  */
 class Zend_Service_WindowsAzure_CommandLine_Certificate
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * List certificates for a specified hosted service in a specified subscription.
-	 * 
+	 *
 	 * @command-name List
 	 * @command-description List certificates for a specified hosted service in a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -70,10 +80,10 @@ class Zend_Service_WindowsAzure_CommandLine_Certificate
 			$this->_displayObjectInformation($object, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
 		}
 	}
-	
+
 	/**
 	 * Add a certificate for a specified hosted service in a specified subscription.
-	 * 
+	 *
 	 * @command-name Add
 	 * @command-description Add a certificate for a specified hosted service in a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -95,10 +105,10 @@ class Zend_Service_WindowsAzure_CommandLine_Certificate
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Gets a certificate from a specified hosted service in a specified subscription.
-	 * 
+	 *
 	 * @command-name Get
 	 * @command-description Gets a certificate from a specified hosted service in a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -117,10 +127,10 @@ class Zend_Service_WindowsAzure_CommandLine_Certificate
 
 		$this->_displayObjectInformation($result, array('Thumbprint', 'CertificateUrl', 'ThumbprintAlgorithm'));
 	}
-	
+
 	/**
 	 * Gets a certificate property from a specified hosted service in a specified subscription.
-	 * 
+	 *
 	 * @command-name GetProperty
 	 * @command-description Gets a certificate property from a specified hosted service in a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -140,10 +150,10 @@ class Zend_Service_WindowsAzure_CommandLine_Certificate
 
 		printf("%s\r\n", $result->$property);
 	}
-	
+
 	/**
 	 * Deletes a certificate from a specified hosted service in a specified subscription.
-	 * 
+	 *
 	 * @command-name Delete
 	 * @command-description Deletes a certificate from a specified hosted service in a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.

+ 72 - 67
library/Zend/Service/WindowsAzure/CommandLine/Deployment.php

@@ -26,22 +26,27 @@
 require_once 'Zend/Service/Console/Command.php';
 
 /**
+ * @see Zend_Service_WindowsAzure_Management_Client
+ */
+require_once 'Zend/Service/WindowsAzure/Management/Client.php';
+
+/**
  * Deployment commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler deployment
  * @command-handler-description Windows Azure Deployment commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer Note: Parameters that are common across all commands can be stored 
+ * @command-handler-footer Note: Parameters that are common across all commands can be stored
  * @command-handler-footer in two dedicated environment variables.
  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -49,10 +54,10 @@ require_once 'Zend/Service/Console/Command.php';
  */
 class Zend_Service_WindowsAzure_CommandLine_Deployment
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * Creates a deployment from a remote package file and service configuration.
-	 * 
+	 *
 	 * @command-name CreateFromStorage
 	 * @command-description Creates a deployment from a remote package file and service configuration.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -92,10 +97,10 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Creates a deployment from a local package file and service configuration.
-	 * 
+	 *
 	 * @command-name CreateFromLocal
 	 * @command-description Creates a deployment from a local package file and service configuration.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -134,21 +139,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 		$blobClient->createContainerIfNotExists('phpazuredeployments');
 		$blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation);
 		$package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation));
-		
+
 		$client->createDeployment($serviceName, $deploymentSlot, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $startImmediately, $warningsAsErrors);
 
 		$client->waitForOperation();
 		$blobClient->deleteBlob('phpazuredeployments', basename($packageLocation));
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Get deployment properties.
-	 * 
+	 *
 	 * @command-name GetProperties
 	 * @command-description Get deployment properties.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -163,12 +168,12 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	public function getPropertiesCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName)
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
-		
+
 		$result = null;
-		
+
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
 		} else {
 			$result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
@@ -176,10 +181,10 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		$this->_displayObjectInformation($result, array('Name', 'DeploymentSlot', 'Label', 'Url', 'Status'));
 	}
-	
+
 	/**
 	 * Get hosted service account property.
-	 * 
+	 *
 	 * @command-name GetProperty
 	 * @command-description Get deployment property.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -196,12 +201,12 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	public function getPropertyCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $property)
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
-		
+
 		$result = null;
-		
+
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$result = $client->getDeploymentBySlot($serviceName, $deploymentSlot);
 		} else {
 			$result = $client->getDeploymentByDeploymentId($serviceName, $deploymentName);
@@ -209,10 +214,10 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		printf("%s\r\n", $result->$property);
 	}
-	
+
 	/**
 	 * Swap deployment slots (perform VIP swap).
-	 * 
+	 *
 	 * @command-name Swap
 	 * @command-description Swap deployment slots (perform VIP swap).
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -226,13 +231,13 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	public function swapCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $waitForOperation = false)
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
-		
+
 		$productionDeploymentName = null;
 		try { $productionDeploymentName = $client->getDeploymentBySlot($serviceName, 'production')->Name; } catch (Exception $ex) {}
-		
+
 		$stagingDeploymentName = null;
 		try { $stagingDeploymentName = $client->getDeploymentBySlot($serviceName, 'staging')->Name; } catch (Exception $ex) {}
-		
+
 		if (is_null($productionDeploymentName)) {
 			$productionDeploymentName = $stagingDeploymentName;
 		}
@@ -242,16 +247,16 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 		}
 
 		$client->swapDeployment($serviceName, $productionDeploymentName, $stagingDeploymentName);
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Deletes a deployment.
-	 * 
+	 *
 	 * @command-name Delete
 	 * @command-description Deletes a deployment.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -270,21 +275,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->deleteDeploymentBySlot($serviceName, $deploymentSlot);
 		} else {
 			$client->deleteDeploymentByDeploymentId($serviceName, $deploymentName);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Updates a deployment's configuration.
-	 * 
+	 *
 	 * @command-name UpdateConfig
 	 * @command-description Updates a deployment's configuration.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -306,21 +311,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->configureDeploymentBySlot($serviceName, $deploymentSlot, $serviceConfigurationLocation);
 		} else {
 			$client->configureDeploymentByDeploymentId($serviceName, $deploymentName, $serviceConfigurationLocation);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Updates a deployment's status.
-	 * 
+	 *
 	 * @command-name UpdateStatus
 	 * @command-description Updates a deployment's status.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -342,21 +347,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->updateDeploymentStatusBySlot($serviceName, $deploymentSlot, $newStatus);
 		} else {
 			$client->updateDeploymentStatusByDeploymentId($serviceName, $deploymentName, $newStatus);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Updates the number of instances.
-	 * 
+	 *
 	 * @command-name EditInstanceNumber
 	 * @command-description Updates the number of instances.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -379,21 +384,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->setInstanceCountBySlot($serviceName, $deploymentSlot, $roleName, $newInstanceNumber);
 		} else {
 			$client->setInstanceCountByDeploymentId($serviceName, $deploymentName, $roleName, $newInstanceNumber);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Reboots a role instance.
-	 * 
+	 *
 	 * @command-name RebootInstance
 	 * @command-description Reboots a role instance.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -415,21 +420,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->rebootRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName);
 		} else {
 			$client->rebootRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Reimages a role instance.
-	 * 
+	 *
 	 * @command-name ReimageInstance
 	 * @command-description Reimages a role instance.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -451,21 +456,21 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->reimageRoleInstanceBySlot($serviceName, $deploymentSlot, $instanceName);
 		} else {
 			$client->reimageRoleInstanceByDeploymentId($serviceName, $deploymentName, $instanceName);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Upgrades a deployment from a remote package file and service configuration.
-	 * 
+	 *
 	 * @command-name UpgradeFromStorage
 	 * @command-description Upgrades a deployment from a remote package file and service configuration.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -482,26 +487,26 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	 * @command-parameter-for $waitForOperation Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --WaitFor|-w Optional. Wait for the operation to complete?
 	 */
 	public function upgradeFromStorageCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $mode = 'auto', $roleName = null, $waitForOperation = false)
-	{		
+	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $packageUrl, $serviceConfigurationLocation, $mode, $roleName);
 		} else {
 			$client->upgradeDeploymentByDeploymentId($serviceName, $deploymentName, $label, $packageUrl, $serviceConfigurationLocation, $mode, $roleName);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Upgrades a deployment from a local package file and service configuration.
-	 * 
+	 *
 	 * @command-name UpgradeFromLocal
 	 * @command-description Upgrades a deployment from a local package file and service configuration.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -521,32 +526,32 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	public function upgradeFromLocalCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $label, $packageLocation, $serviceConfigurationLocation, $storageAccount, $mode = 'auto', $roleName = null, $waitForOperation = false)
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
-		
+
 		$blobClient = $client->createBlobClientForService($storageAccount);
 		$blobClient->createContainerIfNotExists('phpazuredeployments');
 		$blobClient->putBlob('phpazuredeployments', basename($packageLocation), $packageLocation);
 		$package = $blobClient->getBlobInstance('phpazuredeployments', basename($packageLocation));
-		
+
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->upgradeDeploymentBySlot($serviceName, $deploymentSlot, $label, $package->Url, $serviceConfigurationLocation, $mode, $roleName);
 		} else {
 			$client->upgradeDeploymentByDeploymentId($serviceName, $deploymentName, $label, $package->Url, $serviceConfigurationLocation, $mode, $roleName);
 		}
-		
+
 		$client->waitForOperation();
 		$blobClient->deleteBlob('phpazuredeployments', basename($packageLocation));
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Walks upgrade domains.
-	 * 
+	 *
 	 * @command-name WalkUpgradeDomains
 	 * @command-description Walks upgrade domains.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -561,15 +566,15 @@ class Zend_Service_WindowsAzure_CommandLine_Deployment
 	public function walkUpgradeDomainsCommand($subscriptionId, $certificate, $certificatePassphrase, $serviceName, $deploymentSlot, $deploymentName, $upgradeDomain, $waitForOperation = false)
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
-		
+
 		if (!is_null($deploymentSlot) && $deploymentSlot != '') {
 			$deploymentSlot = strtolower($deploymentSlot);
-			
+
 			$client->walkUpgradeDomainBySlot($serviceName, $deploymentSlot, $upgradeDomain);
 		} else {
 			$client->walkUpgradeDomainByDeploymentId($serviceName, $deploymentName, $upgradeDomain);
 		}
-		
+
 		if ($waitForOperation) {
 			$client->waitForOperation();
 		}

+ 18 - 8
library/Zend/Service/WindowsAzure/CommandLine/GetAsynchronousOperation.php

@@ -21,22 +21,32 @@
  */
 
 /**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
+
+/**
+* @see Zend_Service_WindowsAzure_Management_Client
+*/
+require_once 'Zend/Service/WindowsAzure/Management/Client.php';
+
+/**
  * Asynchronous Operation commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler getasynchronousoperation
  * @command-handler-description Windows Azure Asynchronous Operation commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer Note: Parameters that are common across all commands can be stored 
+ * @command-handler-footer Note: Parameters that are common across all commands can be stored
  * @command-handler-footer in two dedicated environment variables.
  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -44,10 +54,10 @@
  */
 class Zend_Service_WindowsAzure_CommandLine_GetAsynchronousOperation
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * Get information for a specific asynchronous request.
-	 * 
+	 *
 	 * @command-name GetInfo
 	 * @command-description Get information for a specific asynchronous request.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -64,10 +74,10 @@ class Zend_Service_WindowsAzure_CommandLine_GetAsynchronousOperation
 
 		$this->_displayObjectInformation($result, array('ID', 'Status', 'ErrorMessage'));
 	}
-	
+
 	/**
 	 * Wait for a specific asynchronous request to complete.
-	 * 
+	 *
 	 * @command-name WaitFor
 	 * @command-description Wait for a specific asynchronous request to complete.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.

+ 28 - 23
library/Zend/Service/WindowsAzure/CommandLine/Package.php

@@ -24,18 +24,23 @@
 require_once 'Zend/Xml/Security.php';
 
 /**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
+
+/**
  * Package commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler package
  * @command-handler-description Windows Azure Package commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -43,15 +48,15 @@ require_once 'Zend/Xml/Security.php';
  */
 class Zend_Service_WindowsAzure_CommandLine_Package
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * Scaffolds a Windows Azure project structure which can be customized before packaging.
-	 * 
+	 *
 	 * @command-name Scaffold
 	 * @command-description Scaffolds a Windows Azure project structure which can be customized before packaging.
-	 * 
+	 *
 	 * @command-parameter-for $path Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to create the Windows Azure project structure.
-	 * @command-parameter-for $scaffolder Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Scaffolder|-s Optional. The path to the scaffolder to use. Defaults to Scaffolders/DefaultScaffolder.phar 
+	 * @command-parameter-for $scaffolder Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --Scaffolder|-s Optional. The path to the scaffolder to use. Defaults to Scaffolders/DefaultScaffolder.phar
 	 */
 	public function scaffoldCommand($path, $scaffolder, $argv)
 	{
@@ -60,13 +65,13 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 			$scaffolder = dirname(__FILE__) . '/Scaffolders/DefaultScaffolder.phar';
 		}
 		$scaffolder = realpath($scaffolder);
-		
+
 		// Verify scaffolder
 		if (!is_file($scaffolder)) {
 			require_once 'Zend/Service/Console/Exception.php';
 			throw new Zend_Service_Console_Exception('Could not locate the given scaffolder: ' . $scaffolder);
 		}
-		
+
 		// Include scaffolder
 		$archive = new Phar($scaffolder);
 		include $scaffolder;
@@ -74,7 +79,7 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 			require_once 'Zend/Service/Console/Exception.php';
 			throw new Zend_Service_Console_Exception('Could not locate a class named Scaffolder in the given scaffolder: ' . $scaffolder . '. Make sure the scaffolder package contains a file named index.php and contains a class named Scaffolder.');
 		}
-		
+
 		// Cleanup $argv
 		$options = array();
 		foreach ($argv as $arg) {
@@ -84,22 +89,22 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 			}
 			$options[$key] = $value;
 		}
-		
+
 		// Run scaffolder
 		$scaffolderInstance = new Scaffolder();
 		$scaffolderInstance->invoke($archive, $path, $options);
 	}
-	
+
 
 	/**
 	 * Packages a Windows Azure project structure.
-	 * 
+	 *
 	 * @command-name Create
 	 * @command-description Packages a Windows Azure project structure.
-	 * 
+	 *
 	 * @command-parameter-for $path Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to package.
 	 * @command-parameter-for $runDevFabric Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --RunDevFabric|-dev Required. Switch. Run and deploy to the Windows Azure development fabric.
-	 * @command-parameter-for $outputPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutputPath|-out Optional. The output path for the resulting package. 
+	 * @command-parameter-for $outputPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutputPath|-out Optional. The output path for the resulting package.
 	 */
 	public function createPackageCommand($path, $runDevFabric, $outputPath)
 	{
@@ -120,7 +125,7 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 		}
 		$cspack = '"' . $windowsAzureSdkFolderCandidates[0] . '\cspack.exe' . '"';
 		$csrun = '"' . $windowsAzureSdkFolderCandidates[0] . '\csrun.exe' . '"';
-		
+
 		// Open the ServiceDefinition.csdef file and check for role paths
 		$serviceDefinitionFile = $path . '/ServiceDefinition.csdef';
 		if (!file_exists($serviceDefinitionFile)) {
@@ -143,7 +148,7 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 	    		$xmlRoles = array_merge($xmlRoles, array($serviceDefinition->WorkerRole));
 	    	}
 		}
-    		
+
 		// Build '/role:' command parameter
 		$roleArgs = array();
 		foreach ($xmlRoles as $xmlRole) {
@@ -151,7 +156,7 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 				$roleArgs[] = '/role:' . $xmlRole["name"] . ';' . realpath($path . '/' . $xmlRole["name"]);
 			}
 		}
-		
+
 		// Build command
 		$command = $cspack;
 		$args = array(
@@ -163,14 +168,14 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 			$args[] = '/copyOnly';
 		}
 		passthru($command . ' ' . implode(' ', $args));
-		
+
 		// Can we copy a configuration file?
 		$serviceConfigurationFile = $path . '/ServiceConfiguration.cscfg';
 		$serviceConfigurationFileOut = $outputPath . '/ServiceConfiguration.cscfg';
 		if (file_exists($serviceConfigurationFile) && !file_exists($serviceConfigurationFileOut)) {
 			copy($serviceConfigurationFile, $serviceConfigurationFileOut);
 		}
-		
+
 		// Do we have to start the development fabric?
 		if ($runDevFabric) {
 			passthru($csrun . ' /devstore:start /devfabric:start');
@@ -178,13 +183,13 @@ class Zend_Service_WindowsAzure_CommandLine_Package
 			passthru($csrun . ' /run:"' . $packageOut . ';' . $serviceConfigurationFileOut . '" /launchBrowser');
 		}
 	}
-	
+
 	/**
 	 * Creates a scaffolder from a given path.
-	 * 
+	 *
 	 * @command-name CreateScaffolder
 	 * @command-description Creates a scaffolder from a given path.
-	 * 
+	 *
 	 * @command-parameter-for $rootPath Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --Path|-p Required. The path to package into a scaffolder.
 	 * @command-parameter-for $scaffolderFile Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile --OutFile|-out Required. The filename of the scaffolder.
 	 */

+ 27 - 18
library/Zend/Service/WindowsAzure/CommandLine/Service.php

@@ -20,24 +20,33 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
+/**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
+
+/**
+* @see Zend_Service_WindowsAzure_Management_Client
+*/
+require_once 'Zend/Service/WindowsAzure/Management/Client.php';
 
 /**
  * Service commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler service
  * @command-handler-description Windows Azure Service commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer Note: Parameters that are common across all commands can be stored 
+ * @command-handler-footer Note: Parameters that are common across all commands can be stored
  * @command-handler-footer in two dedicated environment variables.
  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -45,10 +54,10 @@
  */
 class Zend_Service_WindowsAzure_CommandLine_Service
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * List hosted service accounts for a specified subscription.
-	 * 
+	 *
 	 * @command-name List
 	 * @command-description List hosted service accounts for a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -69,10 +78,10 @@ class Zend_Service_WindowsAzure_CommandLine_Service
 			$this->_displayObjectInformation($object, array('ServiceName', 'Url'));
 		}
 	}
-	
+
 	/**
 	 * Get hosted service account properties.
-	 * 
+	 *
 	 * @command-name GetProperties
 	 * @command-description Get hosted service account properties.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -87,13 +96,13 @@ class Zend_Service_WindowsAzure_CommandLine_Service
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getHostedServiceProperties($serviceName);
-		
+
 		$this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location'));
 	}
-	
+
 	/**
 	 * Get hosted service account property.
-	 * 
+	 *
 	 * @command-name GetProperty
 	 * @command-description Get storage account property.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -109,13 +118,13 @@ class Zend_Service_WindowsAzure_CommandLine_Service
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getHostedServiceProperties($serviceName);
-		
+
 		printf("%s\r\n", $result->$property);
 	}
-	
+
 	/**
 	 * Create hosted service account.
-	 * 
+	 *
 	 * @command-name Create
 	 * @command-description Create hosted service account.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -139,10 +148,10 @@ class Zend_Service_WindowsAzure_CommandLine_Service
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Update hosted service account.
-	 * 
+	 *
 	 * @command-name Update
 	 * @command-description Update hosted service account.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -164,10 +173,10 @@ class Zend_Service_WindowsAzure_CommandLine_Service
 		}
 		echo $client->getLastRequestId();
 	}
-	
+
 	/**
 	 * Delete hosted service account.
-	 * 
+	 *
 	 * @command-name Delete
 	 * @command-description Delete hosted service account.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.

+ 29 - 20
library/Zend/Service/WindowsAzure/CommandLine/Storage.php

@@ -20,24 +20,33 @@
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
  */
 
+/**
+* @see Zend_Service_Console_Command
+*/
+require_once 'Zend/Service/Console/Command.php';
+
+/**
+* @see Zend_Service_WindowsAzure_Management_Client
+*/
+require_once 'Zend/Service/WindowsAzure/Management/Client.php';
 
 /**
  * Storage commands
- * 
+ *
  * @category   Zend
  * @package    Zend_Service_WindowsAzure_CommandLine
  * @copyright  Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  * @license    http://framework.zend.com/license/new-bsd     New BSD License
- * 
+ *
  * @command-handler storage
  * @command-handler-description Windows Azure Storage commands
  * @command-handler-header Windows Azure SDK for PHP
  * @command-handler-header Copyright (c) 2009 - 2011, RealDolmen (http://www.realdolmen.com)
- * @command-handler-footer Note: Parameters that are common across all commands can be stored 
+ * @command-handler-footer Note: Parameters that are common across all commands can be stored
  * @command-handler-footer in two dedicated environment variables.
  * @command-handler-footer - SubscriptionId: The Windows Azure Subscription Id to operate on.
  * @command-handler-footer - Certificate The Windows Azure .cer Management Certificate.
- * @command-handler-footer 
+ * @command-handler-footer
  * @command-handler-footer All commands support the --ConfigurationFile or -F parameter.
  * @command-handler-footer The parameter file is a simple INI file carrying one parameter
  * @command-handler-footer value per line. It accepts the same parameters as one can
@@ -45,10 +54,10 @@
  */
 class Zend_Service_WindowsAzure_CommandLine_Storage
 	extends Zend_Service_Console_Command
-{	
+{
 	/**
 	 * List storage accounts for a specified subscription.
-	 * 
+	 *
 	 * @command-name ListAccounts
 	 * @command-description List storage accounts for a specified subscription.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -69,10 +78,10 @@ class Zend_Service_WindowsAzure_CommandLine_Storage
 			$this->_displayObjectInformation($object, array('ServiceName', 'Url'));
 		}
 	}
-	
+
 	/**
 	 * Get storage account properties.
-	 * 
+	 *
 	 * @command-name GetProperties
 	 * @command-description Get storage account properties.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -87,13 +96,13 @@ class Zend_Service_WindowsAzure_CommandLine_Storage
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getStorageAccountProperties($accountName);
-		
+
 		$this->_displayObjectInformation($result, array('ServiceName', 'Label', 'AffinityGroup', 'Location'));
 	}
-	
+
 	/**
 	 * Get storage account property.
-	 * 
+	 *
 	 * @command-name GetProperty
 	 * @command-description Get storage account property.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -109,13 +118,13 @@ class Zend_Service_WindowsAzure_CommandLine_Storage
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getStorageAccountProperties($accountName);
-		
+
 		printf("%s\r\n", $result->$property);
 	}
-	
+
 	/**
 	 * Get storage account keys.
-	 * 
+	 *
 	 * @command-name GetKeys
 	 * @command-description Get storage account keys.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -130,14 +139,14 @@ class Zend_Service_WindowsAzure_CommandLine_Storage
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getStorageAccountKeys($accountName);
-		
+
 		$this->_displayObjectInformation((object)array('Key' => 'primary', 'Value' => $result[0]), array('Key', 'Value'));
 		$this->_displayObjectInformation((object)array('Key' => 'secondary', 'Value' => $result[1]), array('Key', 'Value'));
 	}
-	
+
 	/**
 	 * Get storage account key.
-	 * 
+	 *
 	 * @command-name GetKey
 	 * @command-description Get storage account key.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.
@@ -153,16 +162,16 @@ class Zend_Service_WindowsAzure_CommandLine_Storage
 	{
 		$client = new Zend_Service_WindowsAzure_Management_Client($subscriptionId, $certificate, $certificatePassphrase);
 		$result = $client->getStorageAccountKeys($accountName);
-		
+
 		if (strtolower($key) == 'secondary') {
 			printf("%s\r\n", $result[1]);
 		}
 		printf("%s\r\n", $result[0]);
 	}
-	
+
 	/**
 	 * Regenerate storage account keys.
-	 * 
+	 *
 	 * @command-name RegenerateKeys
 	 * @command-description Regenerate storage account keys.
 	 * @command-parameter-for $subscriptionId Zend_Service_Console_Command_ParameterSource_Argv|Zend_Service_Console_Command_ParameterSource_ConfigFile|Zend_Service_Console_Command_ParameterSource_Env --SubscriptionId|-sid Required. This is the Windows Azure Subscription Id to operate on.