|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
edaa9d |
# help_getOptions.sh -- This function interpretes option arguments
|
|
|
edaa9d |
# passed to `help' functionality through the command-line and defines
|
|
|
edaa9d |
# action names 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.
|
|
|
d286ed |
local ARGSL="quiet,answer-yes,dont-commit-changes,backend:,read,search:,edit,update,copy,delete,rename,style:"
|
|
|
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 )
|
|
|
edaa9d |
# CAUTION: Be sure to sanitate this input value
|
|
|
edaa9d |
# through cli_getRepoName using just the basename of
|
|
|
edaa9d |
# the value provided. Otherwise, functionalities might
|
|
|
edaa9d |
# be executed from unexpected places.
|
|
|
edaa9d |
FLAG_BACKEND="$(cli_getRepoName "$2" -f)"
|
|
|
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 |
;;
|
|
|
d286ed |
|
|
|
d286ed |
--style )
|
|
|
d286ed |
FLAG_STYLE="$2"
|
|
|
d286ed |
shift 2
|
|
|
d286ed |
;;
|
|
|
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 |
|
|
|
4c79b5 |
}
|