|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
3a08eb |
# help_getOptions.sh -- This function interpretes arguments passed to
|
|
|
522184 |
# `help' functionality and calls actions accordingly.
|
|
|
4c79b5 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
3a08eb |
function help_getOptions {
|
|
|
4c79b5 |
|
|
|
2bd980 |
# Define short options we want to support.
|
|
|
2bd980 |
local ARGSS=""
|
|
|
2bd980 |
|
|
|
2bd980 |
# Define long options we want to support.
|
|
|
6150a1 |
local ARGSL="quiet,answer-yes,dont-commit-changes,backend:,read,search:,edit,update,copy,delete,rename,manual:"
|
|
|
2bd980 |
|
|
|
2bd980 |
# Parse arguments using getopt(1) command parser.
|
|
|
793c4c |
cli_parseArguments
|
|
|
2bd980 |
|
|
|
2bd980 |
# Reset positional parameters using output from (getopt) argument
|
|
|
2bd980 |
# parser.
|
|
|
2bd980 |
eval set -- "$ARGUMENTS"
|
|
|
2bd980 |
|
|
|
2bd980 |
# Define action to take for each option passed.
|
|
|
2bd980 |
while true; do
|
|
|
2bd980 |
case "$1" in
|
|
|
2bd980 |
|
|
|
c145a8 |
--quiet )
|
|
|
c145a8 |
FLAG_QUIET="true"
|
|
|
c145a8 |
FLAG_DONT_COMMIT_CHANGES="true"
|
|
|
c145a8 |
shift 1
|
|
|
c145a8 |
;;
|
|
|
c145a8 |
|
|
|
3ccb0a |
--answer-yes )
|
|
|
3ccb0a |
FLAG_ANSWER="true"
|
|
|
3ccb0a |
shift 1
|
|
|
c145a8 |
;;
|
|
|
c145a8 |
|
|
|
c145a8 |
--dont-commit-changes )
|
|
|
c145a8 |
FLAG_DONT_COMMIT_CHANGES="true"
|
|
|
c145a8 |
shift 1
|
|
|
c145a8 |
;;
|
|
|
c145a8 |
|
|
|
522184 |
--backend )
|
|
|
522184 |
MANUAL_BACKEND="$(cli_getRepoName "$2" -f)"
|
|
|
522184 |
shift 2
|
|
|
522184 |
;;
|
|
|
522184 |
|
|
|
6150a1 |
--manual )
|
|
|
6150a1 |
FLAG_MANUAL=$(cli_getRepoName "$2" -f | tr '[:lower:]' '[:upper:]')
|
|
|
6150a1 |
shift 2
|
|
|
6150a1 |
;;
|
|
|
6150a1 |
|
|
|
638bf8 |
--search )
|
|
|
522184 |
ACTIONNAM="searchIndex"
|
|
|
53c4b2 |
FLAG_SEARCH="$2"
|
|
|
53c4b2 |
shift 2
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
2bd980 |
--edit )
|
|
|
522184 |
ACTIONNAM="editEntry"
|
|
|
c145a8 |
shift 1
|
|
|
2bd980 |
;;
|
|
|
1527e4 |
|
|
|
1527e4 |
--copy )
|
|
|
522184 |
ACTIONNAM="copyEntry"
|
|
|
1527e4 |
shift 1
|
|
|
1527e4 |
;;
|
|
|
1527e4 |
|
|
|
1527e4 |
--delete )
|
|
|
522184 |
ACTIONNAM="deleteEntry"
|
|
|
1527e4 |
shift 1
|
|
|
1527e4 |
;;
|
|
|
1527e4 |
|
|
|
1527e4 |
--rename )
|
|
|
522184 |
ACTIONNAM="renameEntry"
|
|
|
1527e4 |
shift 1
|
|
|
1527e4 |
;;
|
|
|
4c79b5 |
|
|
|
638bf8 |
--update )
|
|
|
522184 |
ACTIONNAM="updateOutputFiles"
|
|
|
c145a8 |
shift 1
|
|
|
2bd980 |
;;
|
|
|
4c79b5 |
|
|
|
961d96 |
--read )
|
|
|
522184 |
ACTIONNAM="searchNode"
|
|
|
961d96 |
shift 1
|
|
|
961d96 |
;;
|
|
|
deaa54 |
|
|
|
961d96 |
-- )
|
|
|
961d96 |
# Remove the `--' argument from the list of arguments
|
|
|
961d96 |
# in order for processing non-option arguments
|
|
|
961d96 |
# correctly. At this point all option arguments have
|
|
|
961d96 |
# been processed already but the `--' argument still
|
|
|
961d96 |
# remains to mark ending of option arguments and
|
|
|
961d96 |
# begining of non-option arguments. The `--' argument
|
|
|
961d96 |
# needs to be removed here in order to avoid
|
|
|
961d96 |
# centos-art.sh script to process it as a path inside
|
|
|
961d96 |
# the repository, which obviously is not.
|
|
|
961d96 |
shift 1
|
|
|
2bd980 |
break
|
|
|
bbb90e |
;;
|
|
|
2bd980 |
esac
|
|
|
2bd980 |
done
|
|
|
2bd980 |
|
|
|
c145a8 |
# Redefine ARGUMENTS variable using current positional parameters.
|
|
|
793c4c |
cli_parseArgumentsReDef "$@"
|
|
|
b88dec |
|
|
|
83e726 |
# Verify non-option arguments passed to command-line. If there
|
|
|
83e726 |
# isn't any, redefine the ARGUMENTS variable to use the current
|
|
|
83e726 |
# location the functionality was called from.
|
|
|
83e726 |
if [[ $ARGUMENTS == '' ]];then
|
|
|
83e726 |
ARGUMENTS=${PWD}
|
|
|
83e726 |
fi
|
|
|
83e726 |
|
|
|
4c79b5 |
}
|