Blame Scripts/Bash/Functions/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
#
878a2b
# Copyright (C) 2009, 2010, 2011 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 )
878a2b
                URL='http://www.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --lists )
878a2b
                URL='http://lists.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --wiki )
878a2b
                URL='http://wiki.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --forums )
878a2b
                URL='http://forums.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --bugs )
878a2b
                URL='http://bugs.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --projects )
878a2b
                URL='https://projects.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --projects-artwork )
878a2b
                URL=$(cli_printUrl '--projects')svn/artwork/
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --planet )
878a2b
                URL='http://planet.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --docs )
878a2b
                URL='http://docs.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --mirrors )
878a2b
                URL='http://mirrors.centos.org/'
878a2b
                shift 1
878a2b
                ;;
878a2b
878a2b
            --irc )
878a2b
                URL='http://www.centos.org/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 )
878a2b
                if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then
878a2b
                    URL="${URL}$(cli_getCurrentLocale '--langcode-only')/"
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
}