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

2f43c9
<sect1 id="scripts-bash-cliref">
905b18
c330b0
    <title>Script Command-line Interface</title>
905b18
905b18
    <para>
905b18
        The <command>centos-art.sh</command> script follows a
905b18
        conventional command-line interface where there might be
905b18
        options and non-option arguments in it. As convention, the
905b18
        first non-option argument passed to
905b18
        <command>centos-art.sh</command> script will be the name of
905b18
        the specific function you want to execute (e.g.,
905b18
        <function>render</function>, <function>locale</function>,
905b18
        <function>help</function>, etc.).  This first argument will be
905b18
        immediately removed from the list of arguments passed to
905b18
        <command>centos-art.sh</command> script to leave just the
905b18
        remaining options and non-option arguments passed to it.  At
905b18
        this point, the <command>centos-art.sh</command> script uses
905b18
        the <command>getopt</command> command to retrieve option
905b18
        arguments and remove them from the list of arguments passed to
905b18
        <command>centos-art.sh</command> script.
905b18
    </para>
905b18
905b18
    <para>
905b18
        Once option arguments have been removed from list of arguments
905b18
        passed to <command>centos-art.sh</command> script, non option
905b18
        arguments are processed then.  Non-option arguments will
905b18
        always be paths pointing directories inside your working copy
905b18
        of &TCAR;. These paths can be absolute paths or relative paths
c330b0
        considering the working copy root directory as section. For
905b18
        example, both the absolute path 
47422e
        class="directory">/home/al/Projects/CentOS/artwork/Identity/Themes/</filename>
905b18
        and the relative path 
47422e
        class="directory">Identity/Themes</filename> point to
905b18
        the same location.
905b18
    </para>
905b18
905b18
    <para>
905b18
        To better understand the <command>centos-art.sh</command>
905b18
        command-line interface, let's consider the real command shown
905b18
        in <xref linkend="scripts-bash-cliref-cli-example1" /> as
c330b0
        section.  This command shows the entire command as a list of
905b18
        space-separated arguments. The value of each argument can be
905b18
        reached using special variable names based on the number of
905b18
        arguments passed to the command-line.
905b18
    </para>
905b18
905b18
    <example id="scripts-bash-cliref-cli-example1">
905b18
    <title>The command-line interface</title>
905b18
    <screenshot>
905b18
    <screeninfo>The command-line interface</screeninfo>
905b18
    <mediaobject>
905b18
    <textobject>
905b18
<programlisting>
905b18
   ${0}  | |${1}| |          ${2}            | |    ${3}   |
905b18
---------|-|----|-|--------------------------|-|-----------|
47422e
centos-art render Identity/Images/Themes --with-brands
905b18
---------|-|----|-|--------------------------|-|-----------|
905b18
</programlisting>
905b18
    </textobject>
905b18
    </mediaobject>
905b18
    </screenshot>
905b18
    </example>
905b18
905b18
    <para>
905b18
        In <xref linkend="scripts-bash-cliref-cli-example1" />, the
905b18
        relation between special variables and arguments has the
905b18
        following meaning:
905b18
    </para>
905b18
905b18
    <variablelist>
905b18
    <varlistentry>
905b18
    <term><varname>${0}</varname></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This variable contains the absolute path to the command
905b18
        executed. In case your home directory be 
905b18
        class="directory">/home/john</filename> the value of this
905b18
        argument will be expanded to
905b18
        <filename>/home/john/bin/centos-art</filename> which is a
905b18
        symbolic link to the
47422e
        <filename>${TCAR_WORKDIR}/Scripts/Bash/centos-art.sh</filename>
905b18
        file.
905b18
    </para>
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    <varlistentry>
905b18
    <term><varname>${1}</varname></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This variable contains the first non-option argument we use to
905b18
        determine the specific function environment we want to execute
905b18
        (e.g., <function>render</function> in this case). The position
905b18
        of this information in the command-line is relevant to
905b18
        <command>centos-art.sh</command> script and must not be
905b18
        changed. Possible values to this variable are specified in
905b18
        <xref linkend="scripts-bash-cli-specificfuncs" />.
905b18
    </para>
905b18
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    <varlistentry>
905b18
    <term><varname>${2}</varname></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This variable contains a non-option argument referring a path
905b18
        information inside the working copy of &TCAR;. The specific
905b18
        path information you provide in this variable must be
905b18
        recognized by specific function environment provided in
905b18
        <varname>${1}</varname> variable. The position of path
905b18
        information in the command-line is not relevant to
905b18
        <command>centos-art.sh</command> script and can be changed
905b18
        whenever it doesn't be interpreted as value to
905b18
        <varname>${1}</varname> variable.
905b18
    </para>
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    <varlistentry>
905b18
    <term><varname>${3}</varname></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This variable contains an option argument. The specific option
905b18
        information you provide in this variable must be recognized by
905b18
        specific function environment provided in
905b18
        <varname>${1}</varname> variable. The position of options in
905b18
        the command-line is not relevant to
905b18
        <command>centos-art.sh</command> script and can be changed
905b18
        whenever it doesn't be interpreted as value to
905b18
        <varname>${1}</varname> variable.
905b18
    </para>
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    </variablelist>
905b18
2f43c9
    <sect2 id="scripts-bash-cli-commonoptions">
905b18
    <title>Common Options</title>
905b18
905b18
    <para>
905b18
        As convention, all function specific environments should
905b18
        provide support for the following common options: 
905b18
    </para>
905b18
905b18
    <variablelist>
905b18
    <varlistentry>
905b18
    <term><option>-h</option> | <option>--help</option></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This option makes <command>centos-art.sh</command> script to
905b18
        shows information about the specific function environment
905b18
        (e.g., how to execute it, available options, etc.) set as
905b18
        first non-option argument. For example, if you provide the
905b18
        <command>centos-art render --help</command>, the
905b18
        <command>centos-art.sh</command> script will display to you
905b18
        the information related to the 
47422e
        class="directory">Scripts/Bash/Functions/Render</filename>
905b18
        directory.
905b18
    </para>
905b18
    <para>
905b18
        This information is retrived from <quote>The CentOS Artwork
905b18
        Repository File System (tcar-fs)</quote> documentation manual.
905b18
        This manual is written in Texinfo format and provides a quick
905b18
        way for you to read and browse documentation related to each
905b18
        directory inside &TCAR; as you work with it from a text
905b18
        terminal.
905b18
    </para>
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    <varlistentry>
905b18
    <term><option>-q</option> | <option>--quiet</option></term>
905b18
    <listitem>
905b18
    <para>
905b18
        This option makes the <command>centos-art.sh</command> script
905b18
        to suppress messages sent to standard output. This option
905b18
        doesn't suppress error messages, nor questions related to
905b18
        script execution.
905b18
    </para>
905b18
    </listitem>
905b18
    </varlistentry>
905b18
905b18
    </variablelist>
2f43c9
    </sect2>
905b18
2f43c9
    <sect2 id="scripts-bash-cli-specificoptions">
905b18
    <title>Specific Options</title>
905b18
905b18
    <para>
905b18
        The specific options used by specific and common function
c330b0
        environments are described in their respective sections. See
905b18
        <xref linkend="scripts-bash-cli-specificfuncs" /> and 
905b18
        linkend="scripts-bash-cli-commonfuncs" /> to know which these
c330b0
        sections are.
905b18
    </para>
905b18
905b18
    
905b18
    <title>Specific Function Environments</title>
905b18
    <tgroup cols="2" align="left">
905b18
    
905b18
        <row>
905b18
            <entry>Name</entry>
905b18
            <entry>Description</entry>
905b18
        </row>
905b18
    
905b18
905b18
    
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-prepare" /></entry>
2f43c9
            <entry>Standardize configuration tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-render" /></entry>
2f43c9
            <entry>Standardize rendition tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-locale" /></entry>
2f43c9
            <entry>Standardize localization tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-help" /></entry>
2f43c9
            <entry>Standardize documentation tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-pack" /></entry>
2f43c9
            <entry>Standardize packing tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
905b18
            <entry><xref linkend="scripts-bash-tuneup" /></entry>
2f43c9
            <entry>Standardize maintainance tasks inside &TCAR;</entry>
905b18
        </row>
905b18
        <row>
3b9515
            <entry><xref linkend="scripts-bash-vcs" /></entry>
2f43c9
            <entry>Standardize version control tasks inside &TCAR;</entry>
905b18
        </row>
905b18
    
905b18
    
905b18
    </tgroup>
905b18
    
905b18
905b18
    
905b18
    <title>Common Function Environments</title>
905b18
    <tgroup cols="2" align="left">
905b18
    
905b18
        <row>
905b18
            <entry>Name</entry>
905b18
            <entry>Description</entry>
905b18
        </row>
905b18
    
905b18
905b18
    
905b18
        <row>
905b18
            <entry><literal>cli_checkFiles</literal></entry>
2f43c9
            <entry>...</entry>
905b18
        </row>
905b18
    
905b18
    
905b18
    </tgroup>
905b18
    
905b18
2f43c9
    </sect2>
905b18
2f43c9
    <sect2 id="scripts-bash-cliref-implementation">
905b18
905b18
        <title>Implementation</title>
905b18
905b18
        <para>
905b18
            When a new function is created to
905b18
            <command>centos-art.sh</command> script, it is necessary
905b18
            to consider whether it will use arguments or not. When the
905b18
            function doesn't need arguments (e.g., it exists to
905b18
            redefine values related to global variables only) there is
905b18
            no need to consider a parsing feature for it.  However,
905b18
            when the function does use arguments it is very important
905b18
            to parse them appropriately (e.g., by using a parsing feature like
905b18
            that provided by <command>getopt</command> command).
905b18
        </para>
905b18
905b18
        <para>
c330b0
            In this section will describe how to parse arguments (both
905b18
            option and non-option) inside the
905b18
            <command>centos-art.sh</command> script.  This information
c330b0
            must be used as section whenever you need to create a
905b18
            new function for <command>centos-art.sh</command> script.
905b18
        </para>
905b18
2f43c9
    </sect2>
905b18
2f43c9
</sect1>