|
|
@ -0,0 +1,58 @@ |
|
|
|
# --- SDE-COPYRIGHT-NOTE-BEGIN --- |
|
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch. |
|
|
|
# |
|
|
|
# Filename: lib/sde-wrapper-discriminator.in |
|
|
|
# Copyright (C) 2008 The OpenSDE Project |
|
|
|
# |
|
|
|
# More information can be found in the files COPYING and README. |
|
|
|
# |
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
|
|
# it under the terms of the GNU General Public License as published by |
|
|
|
# the Free Software Foundation; version 2 of the License. A copy of the |
|
|
|
# GNU General Public License can be found in the file COPYING. |
|
|
|
# --- SDE-COPYRIGHT-NOTE-END --- |
|
|
|
|
|
|
|
# include the generic sde_wrapper functions |
|
|
|
. "$SDEROOT/lib/sde-wrapper.in" |
|
|
|
|
|
|
|
# list all the valid discriminators for a given command |
|
|
|
# |
|
|
|
sde_wrapper_discriminator_list() { |
|
|
|
ls -1d "$SDEROOT/bin/sde-$1-"* 2> /dev/null |
|
|
|
} |
|
|
|
|
|
|
|
# return the usage of every discriminator |
|
|
|
sde_wrapper_discriminator_help() { |
|
|
|
local toy= name= desc= aliases= |
|
|
|
cat <<-EOT |
|
|
|
Usage: sde $1 <discriminator> [OPTIONS] [ARGUMENTS] |
|
|
|
|
|
|
|
Available Discriminators: |
|
|
|
EOT |
|
|
|
for toy in $( sde_wrapper_discriminator_list "$1" ); do |
|
|
|
name=$( sde_wrapper_name "$toy" ) |
|
|
|
desc=$( sde_wrapper_desc "$toy" ) |
|
|
|
aliases=$( sde_wrapper_aliases "$toy" ) |
|
|
|
echo " $name${desc:+ $desc}${aliases:+ (Alias: ${aliases// /,})}" |
|
|
|
done |
|
|
|
cat <<-EOT |
|
|
|
|
|
|
|
For more information try: sde $1 <discriminator> --help |
|
|
|
EOT |
|
|
|
exit 1 |
|
|
|
} |
|
|
|
|
|
|
|
sde_wrapper_discriminator() { |
|
|
|
local combin= command="$1"; shift |
|
|
|
if [ "$1" != "${1%-*}" ]; then |
|
|
|
# trying to cheat, no dashes alowed |
|
|
|
return |
|
|
|
elif [ -x "$SDEROOT/bin/sde-$command-$1" ]; then |
|
|
|
# discriminator given explicitly |
|
|
|
echo "$1" |
|
|
|
else |
|
|
|
# given token may be an alias of a valid discriminator for this command |
|
|
|
combin=$( grep -l "^#Alias: $1$" `sde_wrapper_discriminator_list $command` | head -n 1 ) |
|
|
|
echo "$discbin" | sed -e 's,.*/sde-,,' |
|
|
|
fi |
|
|
|
} |