Blame Scripts/Bash/Functions/Svg/svg_vacuumDefs.sh

ae2c20
#!/bin/bash
ae2c20
#
ae2c20
# svg_vacuumDefs.sh -- This function removes all unused items from the
ae2c20
# <lt>defs<gt> section of the SVG file massively.
ae2c20
#
7cd8e9
# Copyright (C) 2009, 2010 Alain Reguera Delgado
ae2c20
# 
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.
ae2c20
# 
ae2c20
# This program is distributed in the hope that it will be useful, but
ae2c20
# WITHOUT ANY WARRANTY; without even the implied warranty of
ae2c20
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ae2c20
# General Public License for more details.
ae2c20
#
ae2c20
# You should have received a copy of the GNU General Public License
ae2c20
# along with this program; if not, write to the Free Software
ae2c20
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
ae2c20
# USA.
7cd8e9
# 
ae2c20
# ----------------------------------------------------------------------
ae2c20
# $Id$
ae2c20
# ----------------------------------------------------------------------
ae2c20
ae2c20
function svg_vacuumDefs {
ae2c20
a33931
    # Define short options we want to support.
a33931
    local ARGSS=""
a33931
a33931
    # Define long options we want to support.
a33931
    local ARGSL="filter:"
a33931
a33931
    # Parse arguments using getopt(1) command parser.
a33931
    cli_doParseArguments
a33931
a33931
    # Reset positional parameters using output from (getopt) argument
a33931
    # parser.
a33931
    eval set -- "$ARGUMENTS"
a33931
a33931
    # Define action to take for each option passed.
a33931
    while true; do
a33931
        case "$1" in
a33931
            --filter )
a33931
               REGEX="$2" 
a33931
               shift 2
a33931
               ;;
a33931
            * )
a33931
                break
a33931
        esac
a33931
    done
a33931
a33931
    # Re-define regular expression to match scalable vector graphic
a33931
    # files only.
6f1211
    REGEX=$(echo "${REGEX}.*\.(svgz|svg)")
a33931
a33931
    # Define list of files to process.
a33931
    cli_getFilesList
a33931
a33931
    # Process list of files.
ae2c20
    for FILE in $FILES;do
3df173
3df173
        # Output action message.
ae2c20
        cli_printMessage "$FILE" 'AsUpdatingLine'
3df173
3df173
        # Vacuum unused svg definition using inkscape.
ae2c20
        inkscape --vacuum-defs $FILE &> /dev/null
3df173
ae2c20
    done
ae2c20
3df173
    # Check repository changes and ask user to commit them up to
3df173
    # central repository.
3df173
    cli_commitRepoChanges
3df173
ae2c20
}