Blame Scripts/Functions/cli_printUrl.sh

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