|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# cli.sh -- This function initializes centos-art command line
|
|
|
4c79b5 |
# interface. Variables defined in this function are accesible by all
|
|
|
4c79b5 |
# other functions. The cli function is the first script executed by
|
|
|
4c79b5 |
# centos-art command-line onces invoked.
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# Copyright (C) 2009, 2010 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4c79b5 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4c79b5 |
# General Public License for more details.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# You should have received a copy of the GNU General Public License
|
|
|
4c79b5 |
# along with this program; if not, write to the Free Software
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function cli {
|
|
|
4c79b5 |
|
|
|
cdebd1 |
# Initialize global variables.
|
|
|
f19466 |
local FUNCNAM=''
|
|
|
f19466 |
local ACTIONNAM=''
|
|
|
f19466 |
local ACTIONVAL=''
|
|
|
cdebd1 |
local REGEX=''
|
|
|
f19466 |
local ARGUMENTS=''
|
|
|
f19466 |
local CLINAME=''
|
|
|
f19466 |
local CLIVERSION=''
|
|
|
f19466 |
local CLIDESCRIP=''
|
|
|
f19466 |
local CLICOPYRIGHT=''
|
|
|
f19466 |
|
|
|
f19466 |
# Define centos-art.sh script personal information.
|
|
|
f19466 |
CLINAME='centos-art.sh'
|
|
|
f19466 |
CLIVERSION='Beta'
|
|
|
f19466 |
CLIDESCRIP="`gettext "Automate frequent tasks inside CentOS Artwork Repository."`"
|
|
|
f19466 |
CLICOPYRIGHT="Copyright (C) 2009, 2010 Alain Reguera Delgado"
|
|
|
f19466 |
|
|
|
f19466 |
# Redefine positional parameters stored inside ARGUMENTS variable.
|
|
|
f19466 |
cli_doParseArgumentsReDef "$@"
|
|
|
f19466 |
|
|
|
f19466 |
# Redefine action variables (i.e., FUNCNAM, ACTIONNAM, and
|
|
|
f19466 |
# ACTIONVAL). As convenction we use the first command-line
|
|
|
f19466 |
# argument position to define FUNCNAM, and second argument
|
|
|
f19466 |
# position to define both ACTIONNAM and ACTIONVAL.
|
|
|
82b8d2 |
cli_getActionArguments
|
|
|
b76c02 |
|
|
|
b76c02 |
# Define default text editors used by centos-art.sh script.
|
|
|
4386e8 |
if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then
|
|
|
4c79b5 |
EDITOR='/usr/bin/vim'
|
|
|
4c79b5 |
fi
|
|
|
b76c02 |
|
|
|
b76c02 |
# Check text editor execution rights.
|
|
|
b76c02 |
cli_checkFiles $EDITOR 'x'
|
|
|
4c79b5 |
|
|
|
f19466 |
# Initialize regular expression (REGEX) used to reduce file
|
|
|
f19466 |
# processing. If no regular expression is defined, set regular
|
|
|
f19466 |
# expression to match everything.
|
|
|
f19466 |
REGEX='.+'
|
|
|
f19466 |
|
|
|
4c79b5 |
# Go to defined actions. Keep the cli_getActions function calling
|
|
|
4c79b5 |
# after all variables and arguments definitions. Reason? To make
|
|
|
4c79b5 |
# all variables and arguments definitions available inside
|
|
|
4c79b5 |
# cli_Actions and subsequent function calls inside it.
|
|
|
f19466 |
cli_getActions
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|