help 434 B

123456789101112131415161718192021222324
  1. #!/bin/bash -e
  2. is_not_a_valid() {
  3. local target=$1
  4. [ ! -x "$target" ] || [ ! -f "$target" ]
  5. }
  6. get_help_statement_for() {
  7. local target=$1
  8. grep '^# help:' $target | sed 's/# help://'
  9. }
  10. cd $(dirname $0)
  11. echo "Targets:"
  12. for target in *; do
  13. is_not_a_valid $target && continue
  14. help_statement=$(get_help_statement_for $target)
  15. if [ -n "$help_statement" ]; then
  16. echo -e " $target: $help_statement"
  17. fi
  18. done