Blame Documentation/Models/Docbook/Tcar-ug/Scripts/Bash/funref.docbook

688046
<sect1 id="scripts-bash-funref">
688046
688046
    <title>Environment Functions Reference</title>
688046
688046
    <para>
688046
        In addition to environment variables described above, the
688046
        centos-art.sh script makes available the following common
688046
        environment functions once it is executed:
688046
    </para>
688046
688046
    <variablelist>
688046
688046
    <varlistentry>
688046
    <term>
688046
        <cmdsynopsis>
688046
            <command>cli_checkFiles</command> 
688046
            <arg choice="req">
688046
            <arg>-d</arg>
688046
            <arg>-e</arg>
688046
            <arg>-f</arg>
688046
            <arg>-h</arg>
688046
            <arg>-x</arg>
688046
            </arg>
688046
            <arg choice="req" rep="repeat"><replaceable>LOCATION</replaceable></arg>
688046
        </cmdsynopsis>
688046
    </term>
688046
    <listitem>
688046
    <para>
688046
        The <function>cli_checkFiles</function> standardizes the way
688046
        files are verified inside the centos-art.sh script. It tries
688046
        to answers questions like <emphasis>Is
688046
        <replaceable>LOCATION</replaceable> a regular file or
688046
        directory?</emphasis> or even, <emphasis>does
688046
        <replaceable>LOCATION</replaceable> have execution
688046
        rights?</emphasis>.  You can provide several
688046
        <replaceable>LOCATION</replaceable> arguments to this function
688046
        in order to perform the verifications over them. Likewise, you
688046
        can combine different options to realize different
688046
        verifications over the same files. In case the verification
688046
        fails, an error message is printed and the script finishes its
688046
        execution.
688046
    </para>
688046
    <para>
688046
        The <function>cli_checkFiles</function> is an interface for
688046
        the <command>test</command> command and accepts the following
688046
        options:
688046
    </para>
688046
    <variablelist>
688046
    <varlistentry>
688046
    <term><option>-d</option></term>
688046
    <listitem>
688046
    <para>
688046
        Verifies whether <replaceable>LOCATION</replaceable> exists
688046
        and is a directory. If it doesn't exists or isn't a directory,
688046
        an error message is printed and the script finishes its
688046
        execution.  Otherwise, if it exists and is a directory, the
688046
        script continues its execution normally.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>-e</option></term>
688046
    <listitem>
688046
    <para>
688046
        Verifies whether <replaceable>LOCATION</replaceable> exists or
688046
        not. If it doesn't exist, an error message is printed and the
688046
        script finishes its execution.  Otherwise, if it does exists,
688046
        the script continues its execution normally.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>-f</option></term>
688046
    <listitem>
688046
    <para>
688046
        Verifies whether <replaceable>LOCATION</replaceable> exists
688046
        and is a regular file. If it doesn't exists or isn't a regular
688046
        file, an error message is printed and the script finishes its
688046
        execution. Otherwise, if it exists and is a regular file, the
688046
        script continues its execution normally.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>-h</option></term>
688046
    <listitem>
688046
    <para>
688046
        Verifies whether <replaceable>LOCATION</replaceable> exists
688046
        and is a symbolic link. If it doesn't exists or isn't a
688046
        symbolic link, an error message is printed and the script
688046
        finishes its execution immediately.  Otherwise, if it does
688046
        exist and is a symbolic link, the script continue its
688046
        execution normally.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>-x</option></term>
688046
    <listitem>
688046
    <para>
688046
        Verifies whether <replaceable>LOCATION</replaceable> exists
688046
        and execution permission is granted. If it doesn't exist or
688046
        hasn't execution permission, the script finishes its execution
688046
        immediately. Otherwise, if it exists and has execution
688046
        permissions, the script continues its execution normally.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    </variablelist>
688046
    <para>
688046
        Use the <function>cli_checkFiles</function> function whenever
688046
        you need to verify files inside the &TCAR;.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    
688046
    <varlistentry>
688046
    <term>
688046
        <cmdsynopsis>
688046
            <command>cli_checkRepoDirSource</command>
688046
        </cmdsynopsis>
688046
    </term>
688046
    <listitem>
688046
688046
    <para>
688046
        The <function>cli_checkRepoDirSource</function> function
688046
        standardizes the path construction to directories inside it
688046
        the working copy, using absolute paths.  This function
688046
        transforms relative paths passed as non-option arguments to
688046
        <command>centos-art.sh</command> script command-line into
688046
        absolute paths inside the working copy and verifies whether
688046
        they really exist as directories inside the working copy or
688046
        not. If the path provided doesn't exist as directory inside
688046
        the working copy, the script will finish its execution
688046
        immediately with an error message. Otherwise, if the directory
688046
        exists, the variable <varname>ACTIONVAL</varname> is redefined
688046
        with the related absolute path for further use.
688046
    </para>
688046
 
688046
    <para>
688046
        Use the <function>cli_checkRepoDirSource</function> function
688046
        whenever you need to be sure that non-option arguments passed
688046
        to <command>centos-art.sh</command> script command-line will
688046
        always point to directories inside the working copy.
688046
    </para>
688046
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term>
688046
        <cmdsynopsis>
688046
            <command>cli_synchronizeRepoChanges</command>
688046
            <arg choice="req" rep="repeat"><replaceable>LOCATION</replaceable></arg>
688046
        </cmdsynopsis>
688046
    </term>
688046
    <listitem>
688046
    <para>
688046
        The <function>cli_synchronizeRepoChanges</function>
688046
        standardizes the way changes are synchronized between the
688046
        working copy and the central repository using
688046
        <replaceable>LOCATION</replaceable> as reference. This
688046
        function is the interface we use inside the
688046
        <command>centos-art.sh</command> script to execute the
688046
        <function>Svn</function> functionality described in 
688046
        linkend="scripts-bash-svn" />.
688046
    </para>
688046
    <para>
688046
        Use <function>cli_synchronizeRepoChanges</function> function
688046
        inside the <command>centos-art.sh</command> script whenever
688046
        you need to synchronize one or more changes at any
688046
        <replaceable>LOCATION</replaceable> inside the working copy.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term>
688046
        <cmdsynopsis>
688046
            <command>cli_printMessage</command>
688046
            <arg choice="req"><replaceable>MESSAGE</replaceable></arg>
688046
            <group choice="opt">
688046
            <arg>--as-separator-line</arg>
688046
            <arg>--as-banner-line</arg>
688046
            <arg>--as-cropping-line</arg>
688046
            <arg>--as-tuningup-line</arg>
688046
            <arg>--as-checking-line</arg>
688046
            <arg>--as-combining-line</arg>
688046
            <arg>--as-creating-line</arg>
688046
            <arg>--as-reading-line</arg>
688046
            <arg>--as-savedas-line</arg>
688046
            <arg>--as-linkto-line</arg>
688046
            <arg>--as-movedto-line</arg>
688046
            <arg>--as-validating-line</arg>
688046
            <arg>--as-template-line</arg>
688046
            <arg>--as-configuration-line</arg>
688046
            <arg>--as-palette-line</arg>
688046
            <arg>--as-reponse-line</arg>
688046
            <arg>--as-request-line</arg>
688046
            <arg>--as-selection-line</arg>
688046
            <arg>--as-error-line</arg>
688046
            <arg>--as-toknowmore-line</arg>
688046
            <arg>--as-yesornorequest-line</arg>
688046
            <arg>--as-notrailingnew-line</arg>
688046
            <arg>--as-stdout-line</arg>
688046
            <arg>--as-stderr-line</arg>
688046
            </group>
688046
        </cmdsynopsis>
688046
    </term>
688046
    <listitem>
688046
    <para>
688046
        The <function>cli_printMessage</function> function
688046
        standardizes the way centos-ar.sh scirpt prints messages. By
688046
        default, centos-art.sh script prints all messages to the
688046
        standard output with the exception of those messages printed
688046
        with the <option>--as-stderr-line</option> option, which are
688046
        printed to standard error output instead.
688046
    </para>
688046
688046
    <para>
688046
        The <function>cli_printMessage</function> function requires
286371
        two arguments.  The first argument specifies the
286371
        <replaceable>MESSAGE</replaceable> you want to print and the
286371
        second argument specifies the FORMAT you'll use to print that
286371
        message. Because this function is so used inside the
286371
        centos-art.sh script, it is convenient to provide localization
286371
        to strings passed as <replaceable>MESSAGE</replaceable> using
688046
        <command>gettext</command> contructions when they aren't
688046
        paths.
688046
    </para>
688046
688046
    <para>
688046
        The <function>cli_printMessage</function> function accepts the
688046
        following formats as second argument:
688046
    </para>
688046
688046
    <variablelist>
688046
    <varlistentry>
688046
    <term><option>--as-separator-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format takes the first character passed as
286371
        <replaceable>MESSAGE</replaceable> and repeats it horizontally
286371
        to build a separator line.  Use this format whenever you need
286371
        to create a logical separation between different actions.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-banner-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format takes the string passed as
286371
        <replaceable>MESSAGE</replaceable> and puts it inside two
286371
        horizontal separator lines. Use this format whenever you need
286371
        to print header information for following lines.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-cropping-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been cropped.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-tuningup-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable>
688046
        generally refers to a file inside the repository.  Use this
688046
        format whenever you need to imply the fact that certain file
688046
        has been tuned-up.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-checking-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been checked or verified
286371
        (e.g., through <function>cli_checkFiles</function>
286371
        functionality).
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-combining-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been combined.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-creating-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been created.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-reading-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been read.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-savedas-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been saved.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-linkto-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been linked.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-movedto-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been moved.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-validating-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file has been validated.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-template-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file is a template or design
286371
        model.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-configuration-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file is a configuration file.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-palette-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format is for two columns messages where
286371
        <replaceable>MESSAGE</replaceable> generally refers to a file
286371
        inside the repository.  Use this format whenever you need to
286371
        imply the fact that certain file is a palette of colors.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-response-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format adds <literal>--></literal> at the begining of the
286371
        string passed as <replaceable>MESSAGE</replaceable>.  Use this
286371
        format whenever you need to imply the fact that certain file
286371
        is considered part of a response. For example, when you need
286371
        to express that a group of files will take ceratin action, you
286371
        can use this option to doing so.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-request-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format prints <replaceable>MESSAGE</replaceable> without
286371
        trailing new line.  Use this format whenever you need to imply
286371
        a question or yes or no request.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-selection-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format uses each word in
286371
        <replaceable>MESSAGE</replaceable> as item of a selection
688046
        list. Use this format whenever you need to select one of the
286371
        items provided as <replaceable>MESSAGE</replaceable>.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-error-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format prints error messages produced by centos-art.sh
688046
        script. It uses the <command>caller</command> built-in command
688046
        to display the line number and the filename where such error
688046
        was triggered. Later, it prints where to find more information
688046
        by using the <option>--as-toknowmore-line</option> option.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-toknowmore-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format takes a function name as
286371
        <replaceable>MESSAGE</replaceable> and prints the command you
286371
        can use to find more information about it. When this option is
286371
        passed the script finishes its execution immediately. This
286371
        option is used in combination with
688046
        <option>--as-error-line</option> to finish the script
688046
        execution after an error.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-yesornorequest-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        This format takes a question as
286371
        <replaceable>MESSAGE</replaceable> and reads a yes or no
688046
        answer. When answer is negative, the script finishes its
688046
        execution immediately. When answer is affirmative, the script
688046
        continues its execution normally. 
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-notrailingnew-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        Print <replaceable>MESSAGE</replaceable> without any trailing
286371
        newline.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-stdout-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        Print <replaceable>MESSAGE</replaceable> to standard output.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    
688046
    <varlistentry>
688046
    <term><option>--as-stderr-line</option></term>
688046
    <listitem>
688046
    <para>
286371
        Print <replaceable>MESSAGE</replaceable> to standard error
286371
        output.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    </variablelist>
688046
    <para>
688046
        Use <function>cli_printMessage</function> function whenever
688046
        you need to print information inside the
688046
        <command>centos-art.sh</command> script.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term>...</term>
688046
    <listitem>
688046
    <para>
688046
        ...
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    </variablelist>
688046
688046
</sect1>
688046