Blame Scripts/Bash/Functions/Report/report.sh

1b9e20
#!/bin/bash
1b9e20
#
1b9e20
# report.sh -- This functionality performs system reports.
1b9e20
#
1b9e20
# Copyright (C) 2012 Alain Reguera Delgado
1b9e20
#
1b9e20
# This program is free software; you can redistribute it and/or modify
1b9e20
# it under the terms of the GNU General Public License as published by
1b9e20
# the Free Software Foundation; either version 2 of the License, or (at
1b9e20
# your option) any later version.
1b9e20
#
1b9e20
# This program is distributed in the hope that it will be useful, but
1b9e20
# WITHOUT ANY WARRANTY; without even the implied warranty of
1b9e20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1b9e20
# General Public License for more details.
1b9e20
#
1b9e20
# You should have received a copy of the GNU General Public License
1b9e20
# along with this program; if not, write to the Free Software
1b9e20
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1b9e20
#
1b9e20
# ----------------------------------------------------------------------
1b9e20
# $Id$
1b9e20
# ----------------------------------------------------------------------
1b9e20
1b9e20
function report {
1b9e20
1b9e20
    local ACTIONNAM=''
1b9e20
    local ACTIONNAMS=''
1b9e20
1b9e20
    # Define list of available sub-functionalities.
1b9e20
    local CLI_SUBFUNC=''
1b9e20
    local CLI_SUBFUNCS=$(cli_getFilesList --maxdepth 1 --mindepth 1 \
1b9e20
        --type d --pattern="^[[:alnum:]/]+$" ${CLI_FUNCDIR}/${CLI_FUNCDIRNAM})
1b9e20
1b9e20
    # Show available sub-functionalities in order to choose one.
1b9e20
    select CLI_SUBFUNC in $(basename $CLI_SUBFUNCS);do
1b9e20
        break
1b9e20
    done 
1b9e20
1b9e20
    # Verify that no empty value be passed as sub-functionality.
1b9e20
    if [[ $CLI_SUBFUNC == '' ]];then
1b9e20
        exit
1b9e20
    fi
1b9e20
1b9e20
    # Make sub-functionality all lower-case. This is required in order
1b9e20
    # to build names correctly when exporting related function files.
1b9e20
    CLI_SUBFUNC=$(cli_getRepoName $CLI_SUBFUNC -f)
1b9e20
1b9e20
    # Initialize specific functionalities. At this point we load all
1b9e20
    # functionalities required into the application's execution
1b9e20
    # environment and make them available, this way, to perform
1b9e20
    # report-specific tasks.
1b9e20
    cli_exportFunctions "${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}/$(cli_getRepoName \
1b9e20
       ${CLI_SUBFUNC} -d)" "${CLI_SUBFUNC}"
1b9e20
1b9e20
    # Execute specific functionality.
1b9e20
    ${CLI_SUBFUNC}
1b9e20
1b9e20
}