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