From 77aa2dfffa76de4481c7d64776e7ebab9c3b668d Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Wed, 26 Jan 2011 11:36:43 -0700 Subject: [PATCH] Improvements to query IMAP script --- imp/bin/query_imap_cache | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/imp/bin/query_imap_cache b/imp/bin/query_imap_cache index 5a78bb759..c135123ef 100755 --- a/imp/bin/query_imap_cache +++ b/imp/bin/query_imap_cache @@ -1,13 +1,13 @@ -#!/bin/env php +#!/usr/bin/env php * @category Horde * @license http://www.fsf.org/copyleft/gpl.html GPL @@ -21,16 +21,16 @@ $c = new Console_Getopt(); $argv = $c->readPHPArgv(); array_shift($argv); $options = $c->getopt2($argv, '', array('user=', 'pass=', 'server=')); + if (PEAR::isError($options)) { - $cli->fatal("Invalid arguments.\n"); + _usage(); } $pass = $server = $user = null; foreach ($options[0] as $val) { switch ($val[0]) { - case '--user': - $user = $val[1]; - break; + case '--help': + _usage(); case '--pass': $pass = $val[1]; @@ -39,6 +39,10 @@ foreach ($options[0] as $val) { case '--server': $server = $val[1]; break; + + case '--user': + $user = $val[1]; + break; } } @@ -293,3 +297,17 @@ while (true) { break; } } + +function _usage() +{ + global $cli; + + $cli->writeln($cli->bold('Usage: query_imap_cache [--user=username]')); + $cli->writeln($cli->bold(' [--pass=password]')); + $cli->writeln($cli->bold(' [--server=serverkey]')); + $cli->writeln(); + $cli->writeln($cli->indent('--pass Use this password (otherwise, is prompted)')); + $cli->writeln($cli->indent('--server Use this server key (otherwise, is prompted)')); + $cli->writeln($cli->indent('--user Use this username (otherwise, is prompted)')); + exit; +} -- 2.11.0