mk-cabal-file 905 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/bash -e
  2. if [ $# -lt 1 ]; then
  3. echo "USAGE: $0 [library name]" >&2
  4. exit 99
  5. elif [ $# -eq 1 ]; then
  6. LIBNAME="$1"
  7. TGT='-'
  8. elif [ $# -eq 2 ]; then
  9. LIBNAME="$1"
  10. TGT="$2"
  11. fi
  12. NAME=$(git config user.name)
  13. EMAIL=$(git config user.email)
  14. USER="${NAME} <${EMAIL}>"
  15. YEAR=$(date '+%Y')
  16. function cabal_file {
  17. cat <<EOF
  18. name: ${LIBNAME}
  19. version: 0.1.0.0
  20. -- synopsis:
  21. -- description:
  22. license: BSD3
  23. license-file: LICENSE
  24. author: ${USER}
  25. maintainer: ${USER}
  26. copyright: ©${YEAR} ${NAME}
  27. -- category:
  28. build-type: Simple
  29. cabal-version: >= 1.12
  30. library
  31. -- exposed-modules:
  32. ghc-options: -Wall
  33. build-depends: base >=4.7 && <4.9
  34. default-language: Haskell2010
  35. default-extensions: OverloadedStrings,
  36. ScopedTypeVariables
  37. EOF
  38. }
  39. if [ "x${TGT}" = "x-" ]; then
  40. cabal_file
  41. else
  42. cabal_file >${TGT}
  43. fi