diff --git a/Automation/Modules/Hello/Manuals/hello.asciidoc b/Automation/Modules/Hello/Manuals/hello.asciidoc new file mode 100644 index 0000000..37f32f6 --- /dev/null +++ b/Automation/Modules/Hello/Manuals/hello.asciidoc @@ -0,0 +1,86 @@ +hello(1) +======== + +Name +---- + +hello - Print out greetings and exit successfully. + +Synopsis +-------- + +*centos-art hello [--help|--version|--debug|--greeting=TEXT|--lowercase|--uppercase]* + +Description +----------- + +The *hello* module is very simple. Its main purpose is to print out +the ``Hello, World!'' greeting to standard output and exit +successfully. You can use options to change the greeting message and +the way it is printed out. The *hello* module provides a very simple +example you can use as base to understand how modules work inside +*centos-art.sh* script and use that knowledge to start writing your +own modules for *centos-art.sh* script. + +Options +------- + +The *hello* module accepts the following options: + +*--help*:: + Print out module's documentation. + +*--version*:: + Print out module's version and legal status. + +*--debug*:: + Run the script in debugging mode. This option is very useful if + you want to get a closer look to the way modules are opened and + closed inside *centos-art.sh* script. + +*--greeting=TEXT*:: + Set a different greeting to be printed out. + +*--lowercase*:: + Print out the greeting in lowercase. + +*--uppercase*:: + Print out the greeting in uppercase. + +Exit Status +----------- + +The *hello* module ends its execution with one of the following exit +status: + +* 0 -- Exit successfully without errors. +* 1 -- Exit with errors. + +Authors +------- + +The *hello* module has received contribution from the following +people: + +* Alain Reguera Delgado , 2013 + +Copyright +--------- + +Copyright (C) 2009-2013 The CentOS Artwork SIG + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at +your option) any later version. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +// vim: set syntax=asciidoc: diff --git a/Automation/Modules/Hello/Manuals/render.conf b/Automation/Modules/Hello/Manuals/render.conf new file mode 100644 index 0000000..d74bd04 --- /dev/null +++ b/Automation/Modules/Hello/Manuals/render.conf @@ -0,0 +1,7 @@ +[hello] +render-type = "asciidoc" +render-flow = "manpage" +render-from = "hello.asciidoc" +locale-from = "${TCAR_SCRIPT_LANG_LC}/hello.asciidoc.po" +formats = "xhtml manpage" +mansect = "1" diff --git a/Automation/Modules/Hello/Modules/Output/Modules/Default/default.sh b/Automation/Modules/Hello/Modules/Output/Modules/Default/default.sh new file mode 100755 index 0000000..db1e962 --- /dev/null +++ b/Automation/Modules/Hello/Modules/Output/Modules/Default/default.sh @@ -0,0 +1,32 @@ +#!/bin/bash +###################################################################### +# +# default.sh -- Print greetings as they come, without any +# modification. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function default { + + tcar_printMessage "${HELLO_GREETING}" --as-stdout-line + +} diff --git a/Automation/Modules/Hello/Modules/Output/Modules/Lowercase/lowercase.sh b/Automation/Modules/Hello/Modules/Output/Modules/Lowercase/lowercase.sh new file mode 100755 index 0000000..62fd435 --- /dev/null +++ b/Automation/Modules/Hello/Modules/Output/Modules/Lowercase/lowercase.sh @@ -0,0 +1,33 @@ +#!/bin/bash +###################################################################### +# +# lowercase.sh -- Print greetings in lowercase. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function lowercase { + + HELLO_GREETING=$(echo ${HELLO_GREETING} | tr '[[:upper:]]' '[[:lower:]]') + + tcar_setModuleEnvironment -m 'default' -t 'sib-module' + +} diff --git a/Automation/Modules/Hello/Modules/Output/Modules/Uppercase/uppercase.sh b/Automation/Modules/Hello/Modules/Output/Modules/Uppercase/uppercase.sh new file mode 100755 index 0000000..7f4a37b --- /dev/null +++ b/Automation/Modules/Hello/Modules/Output/Modules/Uppercase/uppercase.sh @@ -0,0 +1,33 @@ +#!/bin/bash +###################################################################### +# +# uppercase.sh -- Print greetings in uppercase. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function uppercase { + + HELLO_GREETING=$(echo ${HELLO_GREETING} | tr '[[:lower:]]' '[[:upper:]]') + + tcar_setModuleEnvironment -m 'default' -t 'sib-module' + +} diff --git a/Automation/Modules/Hello/Modules/Output/output.sh b/Automation/Modules/Hello/Modules/Output/output.sh new file mode 100755 index 0000000..e73ea12 --- /dev/null +++ b/Automation/Modules/Hello/Modules/Output/output.sh @@ -0,0 +1,35 @@ +#!/bin/bash +###################################################################### +# +# output.sh -- Defines the way greetings are printed out. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function output { + + local HELLO_ACTION='' + + for HELLO_ACTION in ${HELLO_ACTIONS};do + tcar_setModuleEnvironment -m ${HELLO_ACTION} -t 'sub-module' + done + +} diff --git a/Automation/Modules/Hello/hello.sh b/Automation/Modules/Hello/hello.sh new file mode 100755 index 0000000..5a25e6f --- /dev/null +++ b/Automation/Modules/Hello/hello.sh @@ -0,0 +1,44 @@ +#!/bin/bash +###################################################################### +# +# hello.sh -- Print greetings and exit successfully. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function hello { + + # Define default message we want to print. + local HELLO_GREETING="`gettext "Hello, World!"`" + + # Define actions variable. Here is where actions related to + # module-specific options are stored in. + local HELLO_ACTIONS='' + + # Interpret module-specific options and store related actions. + hello_getOptions + + # Initiate actions sub-module. + if [[ -n ${HELLO_ACTIONS} ]];then + tcar_setModuleEnvironment -m 'output' -t 'sub-module' + fi + +} diff --git a/Automation/Modules/Hello/hello_getOptions.sh b/Automation/Modules/Hello/hello_getOptions.sh new file mode 100755 index 0000000..9808cad --- /dev/null +++ b/Automation/Modules/Hello/hello_getOptions.sh @@ -0,0 +1,83 @@ +#!/bin/bash +###################################################################### +# +# hello_getOptions.sh -- Interpret hello module's specific options. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function hello_getOptions { + + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="help::,version,greeting:,lowercase,uppercase" + + # Redefine arguments using getopt(1) command parser. + tcar_setModuleArguments + + # Reset positional parameters on this function, using output + # produced from (getopt) arguments parser. + eval set -- "${TCAR_MODULE_ARGUMENT}" + + # Look for options passed through command-line. + while true; do + case "${1}" in + + --help ) + tcar_printHelp "${2}" + ;; + + --version ) + tcar_printVersion "${TCAR_MODULE_NAME}" + ;; + + --greeting ) + HELLO_GREETING="${2:-${HELLO_GREETING}}" + shift 2 + ;; + + --lowercase ) + HELLO_ACTIONS="lowercase ${HELLO_ACTIONS}" + shift 1 + ;; + + --uppercase ) + HELLO_ACTIONS="uppercase ${HELLO_ACTIONS}" + shift 1 + ;; + + -- ) + shift 1 + break + ;; + esac + done + + # Define actions default value. + HELLO_ACTIONS=${HELLO_ACTIONS:-default} + + # Redefine arguments using current positional parameters. Only + # paths should remain as arguments, at this point. + TCAR_MODULE_ARGUMENT="${@}" + +}