OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.8 KiB

# --- 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" )
printf "%15s %s%s\n" "$name" "${desc:-...}" "${aliases:+ (Alias: ${aliases// /,})}"
done
cat <<-EOT
For more information try: sde $1 <discriminator> --help
EOT
}
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 $( sde_wrapper_name "$combin" )
fi
}