Browse Source

Cleaned bin/sde-help by using lib/sde-wrapper.in

karasz/new-early
Alejandro Mery 17 years ago
parent
commit
79190da0c5
1 changed files with 18 additions and 26 deletions
  1. +18
    -26
      bin/sde-help

+ 18
- 26
bin/sde-help

@ -3,7 +3,7 @@
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: bin/sde-help
# Copyright (C) 2006 - 2007 The OpenSDE Project
# Copyright (C) 2006 - 2008 The OpenSDE Project
#
# More information can be found in the files COPYING and README.
#
@ -22,27 +22,20 @@ set -e
[ -n "$SDEROOT" ] ||
export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
. $SDEROOT/lib/libsde.in
. "$SDEROOT/lib/libsde.in"
. "$SDEROOT/lib/sde-wrapper.in"
help_list() {
local command=
local name= desc= alias=
echo "Available Commands:"
for command in $SDEROOT/bin/sde-*; do
# detect command name
case "$command" in
*/sde-*-*) continue ;;
*/sde-*) id=$( echo "$command" | sed -e 's,.*/sde-,,' )
;;
esac
for command in $( sde_wrapper_command_list ); do
name=$( sde_wrapper_command_name "$command" )
desc=$( sde_wrapper_command_desc "$command" )
aliases=$( sde_wrapper_command_aliases "$command" )
# optional description
desc=$( sed -n -e 's,^#Description: \(.*\)$,\1,p' "$command" )
# and valid aliases
alias=$( sed -n -e 's,^#Alias: \([^ ]*\)$,\1,p' "$command" | tr '\n' ' ' )
echo -e "\t* $id${alias:+\t(${alias%% })}"
echo -e "\t* $name${aliases:+\t(${aliases})}"
if [ -n "$desc" ]; then
echo -e "\t\t$desc"
fi
@ -71,16 +64,15 @@ elif [ "$1" != "${1%-*}" ]; then
# don't accept subcommands
echo_error "Incorrect Syntax."
help_usage
elif [ -x "$SDEROOT/bin/sde-$1" ]; then
help_command "$1"
elif grep -q "^#Alias: $1$" $SDEROOT/bin/sde-* 2> /dev/null; then
# use alias
x="$( grep -l "^#Alias: $1$" $SDEROOT/bin/sde-* 2> /dev/null |
head -n 1 | sed -e 's,.*/sde-,,' )"
help_command "$x"
else
# unknown command
echo_error "Command '$COLOR_MESSAGE$1$COLOR_NORMAL' doesn't exist."
help_list
exit 2
# detect requested command
command="$( sde_wrapper_command "$1" )"
if [ -z "$command" ]; then
# unknown command
echo_error "Command '$COLOR_MESSAGE$1$COLOR_NORMAL' doesn't exist."
help_list
exit 2
else
help_command "$command"
fi
fi

Loading…
Cancel
Save