aboutsummaryrefslogtreecommitdiffstats
path: root/gsxcl
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2011-05-05 09:05:43 +0300
committerFilipp Lepalaan <filipp@mac.com>2011-05-05 09:05:43 +0300
commitd41193438ed67747c448ca71d3030292138e9f4d (patch)
tree853967b33551c9fdb1a73c8d38b45f3eacdd3abb /gsxcl
parent8ba4138f222d483424fe3b3dfefabf63f0e7913a (diff)
downloadgsxlib-d41193438ed67747c448ca71d3030292138e9f4d.tar.gz
gsxlib-d41193438ed67747c448ca71d3030292138e9f4d.tar.bz2
gsxlib-d41193438ed67747c448ca71d3030292138e9f4d.zip
fixed -e and -r defaults
Diffstat (limited to 'gsxcl')
-rwxr-xr-xgsxcl38
1 files changed, 28 insertions, 10 deletions
diff --git a/gsxcl b/gsxcl
index f6d297d..7c09ecb 100755
--- a/gsxcl
+++ b/gsxcl
@@ -21,28 +21,46 @@ if (count($argv) < 6) {
echo <<<EOT
usage: gsxcl -s sold-to -u username -p password [-r region] [-e environment] [-m warranty|parts] [-q query]
- -s sold-to your GSX Sold-To account.
- -u username the Apple ID with GSX WS API access.
- -p password the password for the Apple ID.
+ -s sold-to your GSX Sold-To account
+ -u username the Apple ID with GSX WS API access
+ -p password the password for the Apple ID
-r region either "am" (America), "emea" (Europe, Middle-East, Africa)
"apac" (Asia-Pacific) or "la" (Latin America). Defaults to "emea".
- -e environment the GSX environment. Either empty (production), "it" or "ut".
- Defaults to production.
- -m mode what to search for. Currently one of: {$modes_str}. Defaults to "warranty".
- -q query a query string (serial number, order confirmation, repair number, EEE code, etc.
- Defaults to current serial number.
+ -e environment the GSX environment. Either empty (production), "it" or "ut"
+ Defaults to production
+ -m mode what to search for. Currently one of: {$modes_str}. Defaults to "warranty"
+ -q query a query string (serial number, order confirmation, repair number, EEE code, etc
+ Defaults to this machine's serial number
EOT;
exit();
}
-$opts = getopt('s:u:p:r:e:m:q:');
-$gsx = new GsxLib($opts['s'], $opts['u'], $opts['p'], $opts['e'], $opts['r']);
+$opts = getopt('s:u:p:i::r:e:m:q:');
+$region = ($opts['r']) ? $opts['r'] : 'emea';
+$environment = ($opts['e']) ? $opts['e'] : null;
+
+$gsx = new GsxLib($opts['s'], $opts['u'], $opts['p'], $environment, $region);
if (empty($opts['q'])) {
$opts['q'] = `/usr/sbin/system_profiler SPHardwareDataType | awk '/Serial Number/ {print $4}'`;
}
+if (isset($opts['i']))
+{
+ if (!function_exists('readline')) {
+ exit("Sorry, but your PHP lacks readline support\n");
+ }
+
+ echo "Entering interactive mode\n";
+
+ while ($line != 'quit')
+ {
+ $line = readline('gsx: ');
+ readline_add_history($line);
+ }
+}
+
switch ($opts['m'])
{
case 'warranty':