#!/bin/bash
#
# Lightweight Software Distribution (LSD) Management Script
#

# Parameters
DIRNAME="`dirname $0`"
BASENAME="`basename $0`"
ACTION="$1"

# List apps
function lsd_list {
  #find -maxdepth 2 -iname 'readme*' -exec head -1 {} \; 
  (
  cd $DIRNAME
  find -maxdepth 2 -iname 'readme*' | while read readme; do
    if [ "$readme" == "./README.md" ]; then
      continue
    fi
    
    echo -n "`dirname $readme | sed -e 's/^.\///'`: "
    head -1 $readme
  done
  )
}

# Dispatch
if [ -z "$ACTION" ] || [ "$ACTION" == "list" ]; then
  lsd_list
fi