Net_Dict
[ class tree: Net_Dict ] [ index: Net_Dict ] [ all elements ]

Source for file dict.php

Documentation is available at dict.php

  1. #!/usr/local/bin/php -q
  2. <?php
  3.  
  4. // {{{ includes
  5. require 'Console/Getopt.php';
  6. require 'Net/Dict.php';
  7. // }}}
  8. // {{{ get options
  9.  
  10. $longOptions  = array('help''match=''databases''strategies'
  11.                         'info=''server''status');
  12.  
  13. $con = new Console_Getopt;
  14.  
  15. $args $con->readPHPArgv();
  16.  
  17. // array_shift($args);
  18.  
  19. $options $con->getopt($args''$longOptions);
  20.  
  21. if (PEAR::isError($options)) {
  22.     die($options->getMessage());
  23. }
  24.  
  25. // }}}
  26. // {{{ help!
  27. function help()
  28. {
  29. echo <<<HELP
  30.  
  31. Usage: dict [OPTIONS] keyword
  32.  
  33. Options:
  34.     --help          Prints this help screen
  35.     --matches=word  Show DB matches for word 
  36.     --databases     Show DB list
  37.     --strategies    Show Strategy list
  38.     --info=DATABASE Show Info on DB
  39.     --server        Show Server Info    
  40.     --status        Show Status
  41.  
  42. HELP;
  43.     exit(0);
  44. }
  45.  
  46. if ('--help' == $options[0][0][0or empty($options[0][0][0]and empty($options[1][0]) )  ) help();
  47.  
  48. // }}}
  49. // {{{ connect
  50. $d = new Net_Dict;
  51.  
  52. $conn $d->connect();
  53.  
  54. if (PEAR::isError($conn)) {
  55.     die($conn->getMessage());
  56. }
  57.  
  58. // }}}
  59. // {{{ define
  60.  
  61. if (!empty($options[1][0])) {
  62.  
  63.     foreach ($options[1as $keyword{
  64.     
  65.             $defs $d->define($keyword);
  66.  
  67.             if (PEAR::isError($defs)) {
  68.                     die($defs->getMessage());
  69.             }
  70.  
  71.             foreach ($defs as $def{
  72.                     echo $def['definition'];
  73.             }
  74.     }
  75. }
  76.  
  77. // }}}
  78. // {{{ options 
  79.  
  80. switch ($options[0][0][0]{
  81.  
  82.     case '--help':
  83.         help();
  84.         break;
  85.  
  86.     case '--match':
  87.  
  88.         foreach($d->match($options[0][0][1]as $matches)
  89.             echo $matches['database'' : ' $matches['word'"\n";
  90.    
  91.         break;
  92.  
  93.     case '--databases':
  94.  
  95.         foreach ($d->showDatabases(as $db
  96.             echo $db['database'' : ' $db['description']."\n";
  97.  
  98.         break;
  99.  
  100.     case '--strategies':
  101.         
  102.         foreach ($d->showStrategies(as $strat)
  103.             echo $strat['strategy'' : ' $strat['description'"\n";
  104.  
  105.         break;
  106.  
  107.     case '--info':
  108.  
  109.         $info $d->showInfo($options[0][0][1]);
  110.  
  111.         if (PEAR::isError($info))
  112.             die($info->getMessage());
  113.  
  114.         echo $info;
  115.  
  116.         break;
  117.  
  118.     case '--server':
  119.         
  120.         $server $d->showServer();
  121.  
  122.         if (PEAR::isError($server)) 
  123.             die($server->getMessage());
  124.  
  125.         echo $server;
  126.  
  127.         break;
  128.  
  129.     case '--status':
  130.         
  131.         echo $d->status();
  132.  
  133.         break;
  134.  
  135.     default:
  136.         break;
  137. }
  138.  
  139. // }}}

Documentation generated on Mon, 11 Mar 2019 15:41:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.