|
# --- SDE-COPYRIGHT-NOTE-BEGIN ---
|
|
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
|
|
#
|
|
# Filename: lib/sde-wrapper-command.in
|
|
# Copyright (C) 2006 - 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 command wrappers
|
|
#
|
|
sde_wrapper_command_list() {
|
|
ls -1d "$SDEROOT/bin/sde-"* | grep -v 'bin/sde-.*-.*'
|
|
}
|
|
|
|
sde_wrapper_command_help_list() {
|
|
local command=
|
|
local name= desc= alias=
|
|
|
|
for command in $( sde_wrapper_command_list ); do
|
|
name=$( sde_wrapper_name "$command" )
|
|
desc=$( sde_wrapper_desc "$command" )
|
|
aliases=$( sde_wrapper_aliases "$command" )
|
|
|
|
printf "%15s %s%s\n" "$name" "${desc:-...}" "${aliases:+ (Alias: ${aliases// /,})}"
|
|
done
|
|
}
|
|
|
|
sde_wrapper_command_help() {
|
|
cat <<-EOT
|
|
Usage: sde <command> <discriminator> [OPTIONS] [ARGUMENTS]
|
|
|
|
Available Commands:
|
|
$( sde_wrapper_command_help_list )
|
|
|
|
For more information about try: sde <command> --help
|
|
EOT
|
|
}
|
|
|
|
# checks if a token is a valid command, of an alias of a valid command
|
|
#
|
|
sde_wrapper_command() {
|
|
local cmdbin=
|
|
if [ "$1" != "${1%-*}" ]; then
|
|
# trying to cheat, no dashes alowed
|
|
return
|
|
elif [ -x "$SDEROOT/bin/sde-$1" ]; then
|
|
# command given explicitly
|
|
echo "$1"
|
|
else
|
|
# given token may be an alias of a valid command
|
|
cmdbin=$( grep -l "^#Alias: $1$" `sde_wrapper_command_list` | head -n 1 )
|
|
echo $( sde_wrapper_name "$cmdbin" )
|
|
fi
|
|
}
|