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
688046
        two arguments.  The first argument specifies the MESSAGE you
688046
        want to print and the second argument specifies the FORMAT
688046
        you'll use to print that message. Because this function is so
688046
        used inside the centos-art.sh script, it is convenient to
688046
        provide localization to strings passed as MESSAGE 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>
688046
        This format takes the first character passed as MESSAGE and
688046
        repeats it horizontally to build a separator line.  Use this
688046
        format whenever you need to create a logical separation
688046
        between different actions.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-banner-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format takes the string passed as MESSAGE and puts it
688046
        inside two horizontal separator lines. Use this format
688046
        whenever you need to print header information for following
688046
        lines.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-cropping-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 cropped.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-tuningup-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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>
688046
        This format is for two columns messages where MESSAGE
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 checked or verified (e.g., through
688046
        <function>cli_checkFiles</function> functionality).
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-combining-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 combined.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-creating-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 created.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-reading-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 read.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-savedas-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 saved.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-linkto-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 linked.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-movedto-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 moved.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-validating-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
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 validated.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-template-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
688046
        generally refers to a file inside the repository.  Use this
688046
        format whenever you need to imply the fact that certain file
688046
        is a template or design model.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-configuration-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
688046
        generally refers to a file inside the repository.  Use this
688046
        format whenever you need to imply the fact that certain file
688046
        is a configuration file.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-palette-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format is for two columns messages where MESSAGE
688046
        generally refers to a file inside the repository.  Use this
688046
        format whenever you need to imply the fact that certain file
688046
        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
688046
        string passed as MESSAGE.  Use this format whenever you need
688046
        to imply the fact that certain file is considered part of a
688046
        response. For example, when you need to express that a group
688046
        of files will take ceratin action, you can use this option to
688046
        doing so.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-request-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format prints MESSAGE without trailing new line.  Use
688046
        this format whenever you need to imply a question or yes or no
688046
        request.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    <varlistentry>
688046
    <term><option>--as-selection-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        This format uses each word in MESSAGE as item of a selection
688046
        list. Use this format whenever you need to select one of the
688046
        items provided as MESSAGE.
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>
688046
        This format takes a function name as MESSAGE and prints the
688046
        command you can use to find more information about it. When
688046
        this option is passed the script finishes its execution
688046
        immediately. This 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>
688046
        This format takes a question as MESSAGE 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>
688046
        Print MESSAGE without any trailing newline.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
688046
    <varlistentry>
688046
    <term><option>--as-stdout-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        Print MESSAGE to standard output.
688046
    </para>
688046
    </listitem>
688046
    </varlistentry>
688046
    
688046
    <varlistentry>
688046
    <term><option>--as-stderr-line</option></term>
688046
    <listitem>
688046
    <para>
688046
        Print MESSAGE to standard error 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