/**
  * Convenience constructor for building an argument specification from a
  * dictionary. This just wraps all the setter methods, but allows you to
  * define things a little more compactly. Pass an array of properties:
  *
  *    $spec = PhutilArgumentSpecification::newQuickSpec(
  *      array(
  *        'name'  => 'verbose',
  *        'short' => 'v',
  *      ));
  *
  * Recognized keys and equivalent verbose methods are:
  *
  *    name        setName()
  *    help        setHelp()
  *    short       setShortAlias()
  *    param       setParamName()
  *    default     setDefault()
  *    conflicts   setConflicts()
  *    wildcard    setWildcard()
  *    repeat      setRepeatable()
  *
  * @param dict Dictionary of quick parameter definitions.
  * @return PhutilArgumentSpecification Constructed argument specification.
  */
 public static function newQuickSpec(array $spec)
 {
     $recognized_keys = array('name', 'help', 'short', 'param', 'default', 'conflicts', 'wildcard', 'repeat', 'standard');
     $unrecognized = array_diff_key($spec, array_fill_keys($recognized_keys, true));
     foreach ($unrecognized as $key => $ignored) {
         throw new PhutilArgumentSpecificationException(pht("Unrecognized key '%s' in argument specification. Recognized keys " . "are: %s.", $key, implode(', ', $recognized_keys)));
     }
     $obj = new PhutilArgumentSpecification();
     foreach ($spec as $key => $value) {
         switch ($key) {
             case 'name':
                 $obj->setName($value);
                 break;
             case 'help':
                 $obj->setHelp($value);
                 break;
             case 'short':
                 $obj->setShortAlias($value);
                 break;
             case 'param':
                 $obj->setParamName($value);
                 break;
             case 'default':
                 $obj->setDefault($value);
                 break;
             case 'conflicts':
                 $obj->setConflicts($value);
                 break;
             case 'wildcard':
                 $obj->setWildcard($value);
                 break;
             case 'repeat':
                 $obj->setRepeatable($value);
                 break;
             case 'standard':
                 $obj->setStandard($value);
                 break;
         }
     }
     $obj->validate();
     return $obj;
 }