Blame Scripts/Bash/Functions/cli.sh

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
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.
817c4d
    cli_getArguments
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
79b380
    # Go for function initialization. Keep the cli_getFunctions
79b380
    # function calling after all variables and arguments definitions.
79b380
    cli_getFunctions
4c79b5
4c79b5
}