<?xml version="1.0" encoding="UTF-8"?>
<!-- Reviewed: no -->
<sect1 id="zend.console.getopt.introduction">
    <title>Introduction</title>
    <para>
        The <classname>Zend_Console_Getopt</classname> class helps command-line
        applications to parse their options and arguments.
    </para>
    <para>
        Users may specify command-line arguments when
        they execute your application. These arguments have meaning to the
        application, to change the behavior in some way, or choose resources,
        or specify parameters. Many options have developed customary meaning,
        for example <command>--verbose</command> enables extra output from many
        applications. Other options may have a meaning that is different for
        each application. For example, <command>-c</command> enables different
        features in <command>grep</command>, <command>ls</command>, and
        <command>tar</command>.
    </para>
    <para>
        Below are a few definitions of terms. Common usage of the terms
        varies, but this documentation will use the definitions below.
    </para>
    <itemizedlist>
        <listitem>
            <para>
                "argument": a string that occurs on the command-line
                following the name of the command. Arguments may be
                options or else may appear without an option, to name
                resources on which the command operates.
            </para>
        </listitem>
        <listitem>
            <para>
                "option": an argument that signifies that the command
                should change its default behavior in some way.
            </para>
        </listitem>
        <listitem>
            <para>
                "flag": the first part of an option, identifies
                the purpose of the option. A flag is preceded
                conventionally by one or two dashes
                (<command>-</command> or <command>--</command>).
                A single dash precedes a single-character flag
                or a cluster of single-character flags.
                A double-dash precedes a multi-character flag.
                Long flags cannot be clustered.
            </para>
        </listitem>
        <listitem>
            <para>
                "parameter": the secondary part of an option; a data value
                that may accompany a flag, if it is applicable to the
                given option. For example, many commands accept a
                <command>--verbose</command> option, but typically
                this option has no parameter. However, an option like
                <command>--user</command> almost always requires
                a following parameter.
            </para>
            <para>
                A parameter may be given as a separate argument following a
                flag argument, or as part of the same argument string,
                separated from the flag by an equals symbol (<command>=</command>).
                The latter form is supported only by long flags.
                For example,
                <command>-u username</command>, <command>--user username</command>,
                and <command>--user=username</command> are forms supported
                by <classname>Zend_Console_Getopt</classname>.
            </para>
        </listitem>
        <listitem>
            <para>
                "cluster": multiple single-character flags combined
                in a single string argument and preceded by a single
                dash. For example, "<command>ls -1str</command>"
                uses a cluster of four short flags. This command is
                equivalent to "<command>ls -1 -s -t -r</command>".
                Only single-character flags can be clustered.
                You cannot make a cluster of long flags.
            </para>
        </listitem>
    </itemizedlist>
    <para>
        For example, in <command>mysql --user=root mydatabase</command>,
        <command>mysql</command> is a <emphasis>command</emphasis>,
        <command>--user=root</command> is an <emphasis>option</emphasis>,
        <command>--user</command> is a <emphasis>flag</emphasis>,
        <command>root</command> is a <emphasis>parameter</emphasis> to the option,
        and <command>mydatabase</command> is an argument but not an option
        by our definition.
    </para>
    <para>
        <classname>Zend_Console_Getopt</classname> provides an interface to declare
        which flags are valid for your application, output an error and usage
        message if they use an invalid flag, and report to your application
        code which flags the user specified.
    </para>
    <note>
        <title>Getopt is not an Application Framework</title>
        <para>
            <classname>Zend_Console_Getopt</classname> does <emphasis>not</emphasis>
            interpret the meaning of flags and parameters, nor does this class
            implement application workflow or invoke application code.
            You must implement those actions in your own application code.
            You can use the <classname>Zend_Console_Getopt</classname> class to parse
            the command-line and provide object-oriented methods for querying
            which options were given by a user, but code to use this
            information to invoke parts of your application should be in
            another <acronym>PHP</acronym> class.
        </para>
    </note>
    <para>
        The following sections describe usage of <classname>Zend_Console_Getopt</classname>.
    </para>
</sect1>
