Blame Scripts/Bash/Functions/Commons/cli_printUrl.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# cli_printUrl.sh -- This function standardize the way URLs are
878a2b
# printed inside centos-art.sh script. This function describes the
878a2b
# domain organization of The CentOS Project through its URLs and
878a2b
# provides a way to print them out when needed.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function cli_printUrl {
878a2b
878a2b
    local URL=''
878a2b
878a2b
    # Define short options.
878a2b
    local ARGSS=''
878a2b
878a2b
    # Define long options.
878a2b
    local ARGSL='home,lists,wiki,forums,bugs,planet,docs,mirrors,irc,projects,projects-artwork,cc-sharealike,with-locale,as-html-link'
878a2b
878a2b
    # Define ARGUMENTS as local variable in order to parse options
878a2b
    # internlally.
878a2b
    local ARGUMENTS=''
878a2b
878a2b
    # Redefine ARGUMENTS variable using current positional parameters. 
878a2b
    cli_parseArgumentsReDef "$@"
878a2b
878a2b
    # Redefine ARGUMENTS variable using getopt output.
878a2b
    cli_parseArguments
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS variable.
878a2b
    eval set -- "$ARGUMENTS"
878a2b
878a2b
    # Look for options passed through command-line.
878a2b
    while true; do
878a2b
        case "$1" in
878a2b
878a2b
            --home )
3a9967
                URL="http://${DOMAINNAME_HOME}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --lists )
3a9967
                URL="http://${DOMAINNAME_LISTS}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --wiki )
3a9967
                URL="http://${DOMAINNAME_WIKI}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --forums )
3a9967
                URL="http://${DOMAINNAME_FORUMS}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --bugs )
3a9967
                URL="http://${DOMAINNAME_BUGS}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --projects )
dd5aa1
                URL="https://${DOMAINNAME_PROJECTS}/svn/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --projects-artwork )
4f1b9c
                URL="https://${DOMAINNAME_PROJECTS}/svn/artwork/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --planet )
3a9967
                URL="http://${DOMAINNAME_PLANET}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --docs )
3a9967
                URL="http://${DOMAINNAME_DOCS}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --mirrors )
3a9967
                URL="http://${DOMAINNAME_MIRRORS}/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --irc )
3a9967
                URL="http://${DOMAINNAME_HOME}/modules/tinycontent/index.php?id=8"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --cc-sharealike )
878a2b
                URL="http://creativecommons.org/licenses/by-sa/3.0/"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --with-locale )
9f72d8
                if [[ ! ${LANG} =~ '^en' ]];then
9f72d8
                    URL="${URL}$(${CLI_NAME} locale --get-current-langcode)/"
878a2b
                fi
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --as-html-link )
878a2b
                URL="${URL}"
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            -- )
878a2b
878a2b
                shift 1
878a2b
                break
878a2b
                ;;
878a2b
        esac
878a2b
    done
878a2b
878a2b
    # Print Url.
878a2b
    echo "$URL"
878a2b
878a2b
}