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