cvs: peardoc /fr/package/console/console-getopt intro-options.xml

From: Date: Fri, 15 Oct 2004 06:39:57 +0000
Subject: cvs: peardoc /fr/package/console/console-getopt intro-options.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-4978@lists.php.net to get a copy of this message
moosh Fri Oct 15 02:39:57 2004 EDT Added files: /peardoc/fr/package/console/console-getopt intro-options.xml Log: inital translation http://cvs.php.net/co.php/peardoc/fr/package/console/console-getopt/intro-options.xml?r=1.1&p=1 Index: peardoc/fr/package/console/console-getopt/intro-options.xml +++ peardoc/fr/package/console/console-getopt/intro-options.xml <?xml version="1.0" encoding="iso-8859-1" ?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: moosh Status: started --> <refentry id="package.console.console-getopt.intro-options"> <refnamediv> <refname>Introduction - Options</refname> <refpurpose>Définition et traîtement des options</refpurpose> </refnamediv> <refsect1 id="package.console.console-getopt.intro-options.defining"> <title>Definition des options</title> <para> <function>Getopt</function> supporte deux types d'options: <parameter>les options courtes</parameter> et <parameter>les options longues</parameter> <example> <title>Appel d'un script avec des options courtes et longues</title> <para> <programlisting> # Utilisation d'option courtes <command>myphpscript</command> <parameter>-s -l en -o</parameter> # On utilise les option longues <command>myphpscript</command> <parameter>--silencieux --lang=en --option</parameter> # On mélange les utilisations <command>myphpscript</command> <parameter>-s --lang=en -o</parameter> </programlisting> Vous devez définir quelles options vous désirez supporter. Le second argument de <function>getopt</function> requiert une chaîne contenant tous les caractère acceptés. Pour l'exemple ci-dessus il faudrait au minimum: <programlisting role="php"> $shortoptions = "slo"; </programlisting> L'ordre des caractères n'est pas important. Often you have to define options with (optional) parameters. Pour exprimer que une option requiert un parametre, ajoutez un <quote>:</quote>. Si le paramètre est optionnel, ajoutez deux <quote>:</quote>. <programlisting role="php"> $shortoptions = "sl:o::"; </programlisting> ceci signifie que les appeles suivant sont valides. <programlisting> <command>myphpscript</command> <parameter></parameter> <command>myphpscript</command> <parameter>-s</parameter> <command>myphpscript</command> <parameter>-s -l en </parameter> <command>myphpscript</command> <parameter>-o text </parameter> <command>myphpscript</command> <parameter>-o</parameter> </programlisting> alors que <programlisting> <command>myphpscript</command> <parameter>-l</parameter> </programlisting> n'est pas permis. l'option <parameter>-l</parameter> requiert un paramètre, si elle est utilisée. </para> <para> The long options work equally, but they have to be defined in an array: <programlisting role="php"> $longoptions = array("silencieux", "lang", "option"); </programlisting> For defining optional parameters, use <parameter>'='</parameter> and <parameter>'=='</parameter> like the colon in short options. <programlisting role="php"> $longoptions = array("silencieux", "lang=", "option=="); </programlisting> </para> </example> </para> </refsect1> <refsect1 id="package.console.console-getopt.intro-options.return"> <title>Le tableau des option qui est renvoyé</title> <para> Le retour est un tableau de deux éléments: the list of parsed options and the list of non-option command-line arguments. chaque entrée dans la liste des options parsées est une pair d'éléments - le premier représente l'option, le second représente l'argument de l'option, if there was one, else the value is &null;. </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.pear.doc (#4978) next »