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.

63 lines
1.5 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: bin/sde-help
  6. # Copyright (C) 2006 - 2008 The OpenSDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. #Description: Help about the usage of `sde` and the modules
  16. #Alias: man
  17. set -e
  18. [ -n "$SDEROOT" ] ||
  19. export SDEROOT=$( cd "${0%/*}/.."; pwd -P )
  20. . "$SDEROOT/lib/libsde.in"
  21. . "$SDEROOT/lib/sde-wrapper-command.in"
  22. help_usage() {
  23. cat <<-EOT
  24. Usage: sde help <command>
  25. Available Commands:
  26. $( sde_wrapper_command_help_list )
  27. EOT
  28. exit 1
  29. }
  30. help_command() {
  31. if [ -r "$SDEROOT/doc/man/sde-$1.1" ]; then
  32. man "$SDEROOT/doc/man/sde-$1.1"
  33. else
  34. echo_warning "'$COLOR_MESSAGE${1}$COLOR_NORMAL' doesn't provide help."
  35. fi
  36. }
  37. if [ $# -eq 0 -o -z "$1" ]; then
  38. help_usage
  39. elif [ $# -gt 1 -o "$1" != "${1%-*}" ]; then
  40. # only one argument, and don't accept subcommands
  41. echo_error "Incorrect Syntax."
  42. help_usage
  43. else
  44. # detect requested command
  45. command="$( sde_wrapper_command "$1" )"
  46. if [ -z "$command" ]; then
  47. # unknown command
  48. echo_error "Command '$COLOR_MESSAGE$1$COLOR_NORMAL' doesn't exist."
  49. help_usage
  50. exit 2
  51. else
  52. help_command "$command"
  53. fi
  54. fi