Blame Artworks/Documentation/Docbook/Tcar-ug/Scripts/Bash/cliref.docbook

Alain Reguera Delgado 46de3c
<sect1 id="scripts-bash-cliref">
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <title>Command-line Interface</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The <command>centos-art.sh</command> script follows a
Alain Reguera Delgado 46de3c
        conventional GNU/Linux command-line interface where there
Alain Reguera Delgado 46de3c
        might be options and non-option arguments in it. As convention
Alain Reguera Delgado 46de3c
        to <command>centos-art.sh</command>, the first non-option
Alain Reguera Delgado 46de3c
        argument passed through the command-line will be the name of
Alain Reguera Delgado 46de3c
        the specific function you want to execute (e.g., 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-render" />, 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-locale" />, 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-help" />, etc.).  This first argument
Alain Reguera Delgado 46de3c
        will be immediately removed from the list of arguments passed
Alain Reguera Delgado 46de3c
        to <command>centos-art.sh</command> script leaving just the
Alain Reguera Delgado 46de3c
        remaining options and non-option arguments passed to it. From
Alain Reguera Delgado 46de3c
        this point on, the <command>centos-art.sh</command> script
Alain Reguera Delgado 46de3c
        uses the <command>getopt</command> command to retrieve option
Alain Reguera Delgado 46de3c
        arguments and remove them from the list of arguments passed to
Alain Reguera Delgado 46de3c
        <command>centos-art.sh</command> script.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        To better understand the <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
        command-line interface, consider the command shown in 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-cliref-example1" />.  This example
Alain Reguera Delgado 46de3c
        shows the entire command as a list of space-separated
Alain Reguera Delgado 46de3c
        arguments. Each argument passed in the command-line can be
Alain Reguera Delgado 46de3c
        reached using positional variables as described in 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-cliref-implementation-example1" />.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <example id="scripts-bash-cliref-example1">
Alain Reguera Delgado 46de3c
    <title>The command-line interface</title>
Alain Reguera Delgado 46de3c
    <screenshot>
Alain Reguera Delgado 46de3c
    <screeninfo>The command-line interface</screeninfo>
Alain Reguera Delgado 46de3c
    <mediaobject>
Alain Reguera Delgado 46de3c
    <textobject>
Alain Reguera Delgado 46de3c
<programlisting>
Alain Reguera Delgado 46de3c
centos-art render Identity/Images/Themes --with-brands
Alain Reguera Delgado 46de3c
</programlisting>
Alain Reguera Delgado 46de3c
    </textobject>
Alain Reguera Delgado 46de3c
    </mediaobject>
Alain Reguera Delgado 46de3c
    </screenshot>
Alain Reguera Delgado 46de3c
    </example>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <sect2 id="scripts-bash-cliref-options">
Alain Reguera Delgado 46de3c
    <title>Option Arguments</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        As convention inside the <command>centos-art.sh</command>, all
Alain Reguera Delgado 46de3c
        specific function environments should provide support for the
Alain Reguera Delgado 46de3c
        following option arguments:
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <variablelist>
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>-h</option> | <option>--help</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option makes <command>centos-art.sh</command> to shows
Alain Reguera Delgado 46de3c
        information about the specific function environment (e.g., how
Alain Reguera Delgado 46de3c
        to execute it, available options, etc.) set as first
Alain Reguera Delgado 46de3c
        non-option argument. For example, if you provide the
Alain Reguera Delgado 46de3c
        <command>centos-art render --help</command>, the
Alain Reguera Delgado 46de3c
        <command>centos-art.sh</command> script will display to you
Alain Reguera Delgado 46de3c
        the information related to 
Alain Reguera Delgado 46de3c
        /> functionality.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This information is retrieved from <quote>The CentOS Artwork
Alain Reguera Delgado 46de3c
        Repository File System (tcar-fs)</quote> documentation manual.
Alain Reguera Delgado 46de3c
        This manual is written in Texinfo format and provides a quick
Alain Reguera Delgado 46de3c
        way for you to read and browse documentation related to each
Alain Reguera Delgado 46de3c
        directory inside &TCAR; as you work with it from a text
Alain Reguera Delgado 46de3c
        terminal.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
        Enhancement
Alain Reguera Delgado 46de3c
        ===========
Alain Reguera Delgado 46de3c
        At some point, documentation written in Texinfo format will be
Alain Reguera Delgado 46de3c
        replaced by Docbook format and profiling will be used to reach
Alain Reguera Delgado 46de3c
        documentation model files which will be also transformed
Alain Reguera Delgado 46de3c
        automatically based on the output required. In the case of
Alain Reguera Delgado 46de3c
        centos-art.sh help functionality, man pages will be used as
Alain Reguera Delgado 46de3c
        default output format.
Alain Reguera Delgado 46de3c
    -->
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>-q</option> | <option>--quiet</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option makes the <command>centos-art.sh</command> script
Alain Reguera Delgado 46de3c
        to suppress messages sent to standard output. This option
Alain Reguera Delgado 46de3c
        doesn't suppress error messages, nor questions related to
Alain Reguera Delgado 46de3c
        script execution.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </variablelist>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The specific option arguments used by function environments
Alain Reguera Delgado 46de3c
        are described individually, as part of each function
Alain Reguera Delgado 46de3c
        environment documentation.  To know more about the specific
Alain Reguera Delgado 46de3c
        options used by function environments, see 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-cliref-specificfuncs" /> and 
Alain Reguera Delgado 46de3c
        linkend="scripts-bash-cliref-commonfuncs" />.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    <title>Specific functions environment</title>
Alain Reguera Delgado 46de3c
    <tgroup cols="2" align="left">
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>Name</entry>
Alain Reguera Delgado 46de3c
            <entry>Description</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-prepare" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize configuration tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-render" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize rendition tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-locale" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize localization tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-help" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize documentation tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-pack" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize packing tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-tuneup" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize maintainance tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry><xref linkend="scripts-bash-vcs" /></entry>
Alain Reguera Delgado 46de3c
            <entry>Standardize version control tasks inside &TCAR;</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    </tgroup>
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    <title>Common functions environment</title>
Alain Reguera Delgado 46de3c
    <tgroup cols="2" align="left">
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>Name</entry>
Alain Reguera Delgado 46de3c
            <entry>Description</entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                <literal>cli_checkFiles</literal>
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize conditional expressions applied to files
Alain Reguera Delgado 46de3c
                (including links and directories) inside the
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_checkRepoDirSource</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize directories' path construction inside the
Alain Reguera Delgado 46de3c
                working copy, using absolute paths.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_expandTMarkers</entry>   
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize translation markers construction and their
Alain Reguera Delgado 46de3c
                related expansion.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_exportFunctions</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way specific functionalities are
Alain Reguera Delgado 46de3c
                exported to <command>centos-art.sh</command> script
Alain Reguera Delgado 46de3c
                environment.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getConfigLines</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way configuration lines are retrieved
Alain Reguera Delgado 46de3c
                form configuration files.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getConfigSectionNames</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way section names are retrieved from
Alain Reguera Delgado 46de3c
                configuration files.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getConfigValue</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way configuration values are retrieved
Alain Reguera Delgado 46de3c
                from configuration files. 
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getFilesList</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way list of files are built inside
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getPathComponent</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way directory structures are organized
Alain Reguera Delgado 46de3c
                inside the working copy of &TCAR;.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getRepoName</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize files and directories name convection
Alain Reguera Delgado 46de3c
                inside the working copy of &TCAR;.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_getTemporalFile</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize temporal files creation.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_parseArgumentsReDef</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Initiate/reset and sanitize positional parameters
Alain Reguera Delgado 46de3c
                passed to this function and creates the list of
Alain Reguera Delgado 46de3c
                arguments that <command>getopt</command> will process.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_parseArguments</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Redefine the <varname>ARGUMENTS</varname> global
Alain Reguera Delgado 46de3c
                variable using <command>getopt</command> output.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_printCopyrightInfo</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the copyright information printed on
Alain Reguera Delgado 46de3c
                content produced by <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
                script.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_printMailingList</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way mailing list addresses are printed
Alain Reguera Delgado 46de3c
                on content produced by
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_printMessage</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way messages are printed by
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_printUrl</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way URLs are printed by
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script. 
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_runFnEnvironment</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
                script is called to itself. 
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Initiates the <command>centos-art.sh</command> script
Alain Reguera Delgado 46de3c
                command-line interface.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_synchronizeRepoChanges</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the way changes are synchronized between
Alain Reguera Delgado 46de3c
                the working copy and the central repository. 
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_terminateScriptExecution</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Standardize the actions that must be realized just
Alain Reguera Delgado 46de3c
                before leaving the script execution (e.g., cleaning
Alain Reguera Delgado 46de3c
                temporal files).
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
        <row>
Alain Reguera Delgado 46de3c
            <entry>cli_unsetFunctions</entry>
Alain Reguera Delgado 46de3c
            <entry>
Alain Reguera Delgado 46de3c
                Unset functionalities from
Alain Reguera Delgado 46de3c
                <command>centos-art.sh</command> script execution
Alain Reguera Delgado 46de3c
                environment.
Alain Reguera Delgado 46de3c
            </entry>
Alain Reguera Delgado 46de3c
        </row>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
    </tgroup>
Alain Reguera Delgado 46de3c
    
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </sect2>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <sect2>
Alain Reguera Delgado 46de3c
    <title>Non-Option Arguments</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Once option arguments have been removed from the list of
Alain Reguera Delgado 46de3c
        arguments passed to <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
        command-line, non-option arguments are processed then.
Alain Reguera Delgado 46de3c
        Non-option arguments will always be paths pointing to
Alain Reguera Delgado 46de3c
        directories inside your working copy of &TCAR; or
Alain Reguera Delgado 46de3c
        documentation entries pointing to specific sections in a
Alain Reguera Delgado 46de3c
        documentation manual. Paths provided in the command-line can
Alain Reguera Delgado 46de3c
        be absolute or relative considering the root directory of the
Alain Reguera Delgado 46de3c
        working copy as start point.  For example, both the absolute
Alain Reguera Delgado 46de3c
        path <quote>
Alain Reguera Delgado 46de3c
        class="directory">${HOME}/Projects/CentOS/artwork/Identity/Themes/</filename></quote>
Alain Reguera Delgado 46de3c
        and the relative path <quote>
Alain Reguera Delgado 46de3c
        class="directory">Identity/Themes</filename></quote> point to
Alain Reguera Delgado 46de3c
        the same location. Documentation entries, on the other hand,
Alain Reguera Delgado 46de3c
        exist to specify the files inside the <quote>
Alain Reguera Delgado 46de3c
        class="directory">Documentation/Models/</filename></quote>
Alain Reguera Delgado 46de3c
        directory structure you want to work with, based on specific
Alain Reguera Delgado 46de3c
        documentation manual components (e.g., manual name, part,
Alain Reguera Delgado 46de3c
        chapter or section). To know more about documentation entries,
Alain Reguera Delgado 46de3c
        see the <xref linkend="scripts-bash-help"/> functionality
Alain Reguera Delgado 46de3c
        reference.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </sect2>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <sect2 id="scripts-bash-cliref-implementation">
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
        <title>Implementation</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
        <para>
Alain Reguera Delgado 46de3c
            The command-line interface of
Alain Reguera Delgado 46de3c
            <command>centos-art.sh</command> script is implemented
Alain Reguera Delgado 46de3c
            individually for each specific function environments it is
Alain Reguera Delgado 46de3c
            made of. Each specific function environment inside the
Alain Reguera Delgado 46de3c
            <command>centos-art.sh</command> has its own command-line
Alain Reguera Delgado 46de3c
            definition and can differ in options when they are
Alain Reguera Delgado 46de3c
            compared one another. The command-line differences between
Alain Reguera Delgado 46de3c
            specific function environments exist as consequence of the
Alain Reguera Delgado 46de3c
            purpose they were designed for (e.g., different purposes,
Alain Reguera Delgado 46de3c
            different options and arguments).  Nevertheless, all
Alain Reguera Delgado 46de3c
            specific function environments use the same base
Alain Reguera Delgado 46de3c
            construction to implement their unique command-line
Alain Reguera Delgado 46de3c
            interfaces (see 
Alain Reguera Delgado 46de3c
            linkend="scripts-bash-cliref-implementation-example1" />).
Alain Reguera Delgado 46de3c
        </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
        <para>
Alain Reguera Delgado 46de3c
            The specific function environments the
Alain Reguera Delgado 46de3c
            <command>centos-art.sh</command> script is made of use the
Alain Reguera Delgado 46de3c
            <quote><filename>Scripts/Bash/Functions/<replaceable>Fname</replaceable>/<replaceable>fname</replaceable>_getOptions.sh</filename></quote>
Alain Reguera Delgado 46de3c
            file to store the
Alain Reguera Delgado 46de3c
            <function><replaceable>fname</replaceable>_getOptions</function>
Alain Reguera Delgado 46de3c
            function definition. This function definition is where you
Alain Reguera Delgado 46de3c
            set the relation between actions to be executed and
Alain Reguera Delgado 46de3c
            arguments passed to <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
            script.  
Alain Reguera Delgado 46de3c
        </para>
Alain Reguera Delgado 46de3c
        
Alain Reguera Delgado 46de3c
        <para>
Alain Reguera Delgado 46de3c
            Basically, when you decide to create new function
Alain Reguera Delgado 46de3c
            environments for the <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
            script, you need to consider whether they will use
Alain Reguera Delgado 46de3c
            arguments from the command-line or not. When the function
Alain Reguera Delgado 46de3c
            environment doesn't need arguments (e.g., it exists to
Alain Reguera Delgado 46de3c
            redefine values related to variables only) there is not
Alain Reguera Delgado 46de3c
            need to consider a parsing feature for it.  However, when
Alain Reguera Delgado 46de3c
            you need to interact with a specific function through the
Alain Reguera Delgado 46de3c
            command-line, you should use the
Alain Reguera Delgado 46de3c
            <function><replaceable>fname</replaceable>_getOptions</function>
Alain Reguera Delgado 46de3c
            function related to your
Alain Reguera Delgado 46de3c
            <function><replaceable>fname</replaceable></function>
Alain Reguera Delgado 46de3c
            function environment to define the way such interaction
Alain Reguera Delgado 46de3c
            will take place.  This way you can control the possible
Alain Reguera Delgado 46de3c
            arguments your function environment will be able to
Alain Reguera Delgado 46de3c
            interpret from the command-line. 
Alain Reguera Delgado 46de3c
        </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <example id="scripts-bash-cliref-implementation-example1">
Alain Reguera Delgado 46de3c
    <title>The command-line implementation</title>
Alain Reguera Delgado 46de3c
    <screenshot>
Alain Reguera Delgado 46de3c
    <screeninfo>The command-line implementation</screeninfo>
Alain Reguera Delgado 46de3c
    <mediaobject>
Alain Reguera Delgado 46de3c
    <textobject>
Alain Reguera Delgado 46de3c
<programlisting>
Alain Reguera Delgado 46de3c
function <replaceable>fname</replaceable>_getOptions {
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Define short options we want to support.
Alain Reguera Delgado 46de3c
    local ARGSS="h,q"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Define long options we want to support.
Alain Reguera Delgado 46de3c
    local ARGSL="help,quiet"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Redefine ARGUMENTS using getopt(1) command parser.
Alain Reguera Delgado 46de3c
    cli_parseArguments
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Redefine positional parameters using ARGUMENTS variable.
Alain Reguera Delgado 46de3c
    eval set -- "$ARGUMENTS"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Look for options passed through command-line.
Alain Reguera Delgado 46de3c
    while true; do
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
        case "$1" in
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            -h | --help )
Alain Reguera Delgado 46de3c
                cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-<replaceable>fname</replaceable>"
Alain Reguera Delgado 46de3c
                shift 1
Alain Reguera Delgado 46de3c
                exit
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            -q | --quiet )
Alain Reguera Delgado 46de3c
                FLAG_QUIET="true"
Alain Reguera Delgado 46de3c
                shift 1
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            -- )
Alain Reguera Delgado 46de3c
                # Remove the `--' argument from the list of arguments
Alain Reguera Delgado 46de3c
                # in order for processing non-option arguments
Alain Reguera Delgado 46de3c
                # correctly. At this point all option arguments have
Alain Reguera Delgado 46de3c
                # been processed already but the `--' argument still
Alain Reguera Delgado 46de3c
                # remains to mark ending of option arguments and
Alain Reguera Delgado 46de3c
                # beginning of non-option arguments. The `--' argument
Alain Reguera Delgado 46de3c
                # needs to be removed here in order to avoid
Alain Reguera Delgado 46de3c
                # centos-art.sh script to process it as a path inside
Alain Reguera Delgado 46de3c
                # the repository, which obviously is not.
Alain Reguera Delgado 46de3c
                shift 1
Alain Reguera Delgado 46de3c
                break
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
        esac
Alain Reguera Delgado 46de3c
    done
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Redefine ARGUMENTS variable using current positional parameters. 
Alain Reguera Delgado 46de3c
    cli_parseArgumentsReDef "$@"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
}
Alain Reguera Delgado 46de3c
</programlisting>
Alain Reguera Delgado 46de3c
</textobject>
Alain Reguera Delgado 46de3c
</mediaobject>
Alain Reguera Delgado 46de3c
</screenshot>
Alain Reguera Delgado 46de3c
</example>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
        <para>
Alain Reguera Delgado 46de3c
            Using the base structure described in 
Alain Reguera Delgado 46de3c
            linkend="scripts-bash-cliref-implementation-example1"/>, you can
Alain Reguera Delgado 46de3c
            create new options so your specific function environment
Alain Reguera Delgado 46de3c
            can express its usefulness.  For example, if you want your
Alain Reguera Delgado 46de3c
            specific function environment to print a greeting on the
Alain Reguera Delgado 46de3c
            screen when the <option>--hello</option> option is passed
Alain Reguera Delgado 46de3c
            through its command-line, you can modify the base
Alain Reguera Delgado 46de3c
            structure shown above with the following:
Alain Reguera Delgado 46de3c
        </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
<programlisting>
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Define long options we want to support.
Alain Reguera Delgado 46de3c
    local ARGSL="help,quiet,hello"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            --hello )
Alain Reguera Delgado 46de3c
                cli_printMessage "`gettext "Hello World!"`"
Alain Reguera Delgado 46de3c
                shift 1
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
</programlisting>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        In case you want to provide an option value in the form
Alain Reguera Delgado 46de3c
        <option>--hello="World"</option>, you can do it as described
Alain Reguera Delgado 46de3c
        below:
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
<programlisting>
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Define long options we want to support.
Alain Reguera Delgado 46de3c
    local ARGSL="help,quiet,hello:"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            --hello )
Alain Reguera Delgado 46de3c
                cli_printMessage "`gettext "Hello"` ${2}"
Alain Reguera Delgado 46de3c
                shift 2
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
</programlisting>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        In this last case, the option value is required. So, if you
Alain Reguera Delgado 46de3c
        provide the <option>--hello</option> option but do not provide
Alain Reguera Delgado 46de3c
        a value for it, an error will be triggered and the script will
Alain Reguera Delgado 46de3c
        finish its execution. To make an option value not-required,
Alain Reguera Delgado 46de3c
        you need to use two colons instead of one when you define the
Alain Reguera Delgado 46de3c
        options, see the following lines: 
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
<programlisting>
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    # Define long options we want to support.
Alain Reguera Delgado 46de3c
    local ARGSL="help,quiet,hello::"
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
            --hello )
Alain Reguera Delgado 46de3c
                cli_printMessage "`gettext "Hello"` ${2}"
Alain Reguera Delgado 46de3c
                shift 2
Alain Reguera Delgado 46de3c
                ;;
Alain Reguera Delgado 46de3c
...
Alain Reguera Delgado 46de3c
</programlisting>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        To know more about the features provided by
Alain Reguera Delgado 46de3c
        <command>getopt</command> command, read its man page (e.g.,
Alain Reguera Delgado 46de3c
        typing the <command>man getopt</command> command in your
Alain Reguera Delgado 46de3c
        terminal). This information will also help you to understand
Alain Reguera Delgado 46de3c
        how to improve the command-line interfaces you create for
Alain Reguera Delgado 46de3c
        the function environments of <command>centos-art.sh</command>
Alain Reguera Delgado 46de3c
        script.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </sect2>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
</sect1>