--- wadf-httpd.orig	2009-07-17 11:56:46.000000000 +0100
+++ wadf-httpd	2009-07-17 11:58:05.000000000 +0100
@@ -30,6 +30,8 @@
 
 $source_conffile = '@cfg_dir@/Tools_WADF/httpd.conf.sample';
 
+$command = null;
+$appname = null;
 $pidfile = "$WADF_HOME/httpd.pid";
 $portfile = "$WADF_HOME/httpd.port";
 $lockfile = "$WADF_HOME/httpd.lock";
@@ -40,14 +42,17 @@
 $default_error_page = "$WADF_HOME/default_error_page.html";
 $prog = 'WADF HTTPD instance';
 
+$argv_pos = 1;
 if (isset($argv) && isset($argv[1]) && $argv[1] == '-V') {
 	print Tools_WADF::getAboutText();
 	exit(0);
 }
 
-if (!isset($argv) && !isset($argv[1])) {
-	print "Usage: wadf-httpd [start|stop|restart|condrestart|reload|reloadstart|status|graceful|configtest]\n";
+if (!isset($argv) || !isset($argv[$argv_pos])) {
+	print "Usage: [-i site]wadf-httpd [start|stop|restart|condrestart|reload|reloadstart|status|graceful|configtest]\n";
 	exit(5);
+} else {
+	$command = $argv[$argv_pos];
 }
 
 $ret = 0;
@@ -184,7 +189,7 @@
 
 function list_vhosts()
 {
-	global $out, $portfile, $vhost_dir, $default_error_page;
+	global $out, $portfile, $vhost_dir, $default_error_page, $appname;
 	
 	$vhosts = Tools_WADF::getDeployedVhosts($vhost_dir);
 	
@@ -194,7 +199,21 @@
 		exit(5);
 	}
 	
-	if (count($vhosts) > 0) {
+	if (!is_null($appname) && isset($vhosts[$appname])) {
+		$out[] = "Listening on port $port configured for " . count($vhosts) . " applications including $appname:";
+		$details = $vhosts[$appname];
+		
+		$out[] = " $appname: (" . $details['working_dir'] . ')' . "\n   ver=" . $details['deploy_version'];
+		foreach ($details['vhosts'] as $vhost_details) {
+			$vhost_details['interface'] = str_replace('*', ":$port", $vhost_details['interface']);
+			
+			$line = '   http://' . $vhost_details['hostname'] . $vhost_details['interface'];
+			if (isset($vhost_details['description'])) {
+				$line .= ' (' . $vhost_details['description'] . ')';
+			}
+			$out[] = $line;
+		}
+	} elseif (count($vhosts) > 0) {
 		$out[] = "Listening on port $port and configured for the following applications:";
 		foreach ($vhosts as $appname => $details) {
 			$out[] = "\n $appname: (" . $details['working_dir'] . ')' . "\n   ver=" . $details['deploy_version'];
@@ -248,7 +267,7 @@
 
 }
 
-switch ($argv[1]) {
+switch ($command) {
 	case 'start':
 		start();
 		break;
