Browse Source

Added mk-cabal scripts

Getty Ritter 8 years ago
parent
commit
69384235be
2 changed files with 106 additions and 0 deletions
  1. 58 0
      scripts/mk-cabal-executable-file
  2. 48 0
      scripts/mk-cabal-file

+ 58 - 0
scripts/mk-cabal-executable-file

@@ -0,0 +1,58 @@
+#!/bin/bash -e
+
+if [ $# -eq 0 ]; then
+	EXENAME="$(basename $(pwd))"
+	TGT="-"
+elif [ $# -eq 1 ]; then
+	EXENAME="$1"
+	TGT='-'
+elif [ $# -eq 2 ]; then
+	EXENAME="$1"
+	TGT="$2"
+else
+	echo "USAGE: $0 [library name]" >&2
+	exit 99
+fi
+
+NAME=$(git config user.name)
+EMAIL=$(git config user.email)
+USER="${NAME} <${EMAIL}>"
+YEAR=$(date '+%Y')
+
+if [ "${CATEGORY}x" = "x" ]; then
+	CAT_LINE="-- category:"
+else
+	CAT_LINE="category:         ${CATEGORY}"
+fi
+
+function cabal_file {
+	cat <<EOF
+name:             ${EXENAME}
+version:          0.1.0.0
+-- synopsis:
+-- description:
+license:          BSD3
+license-file:     LICENSE
+author:           ${USER}
+maintainer:       ${USER}
+copyright:        ©${YEAR} ${NAME}
+${CAT_LINE}
+build-type:       Simple
+cabal-version:    >= 1.12
+
+executable ${EXENAME}
+  hs-source-dirs:      src
+  main-is:             Main.hs
+  default-extensions:  OverloadedStrings,
+                       ScopedTypeVariables
+  ghc-options:         -Wall
+  build-depends:       base >=4.7 && <4.9
+  default-language:    Haskell2010
+EOF
+}
+
+if [ "x${TGT}" = "x-" ]; then
+	cabal_file
+else
+	cabal_file >${TGT}
+fi

+ 48 - 0
scripts/mk-cabal-file

@@ -0,0 +1,48 @@
+#!/bin/bash -e
+
+if [ $# -lt 1 ]; then
+	echo "USAGE: $0 [library name]" >&2
+	exit 99
+elif [ $# -eq 1 ]; then
+	LIBNAME="$1"
+	TGT='-'
+elif [ $# -eq 2 ]; then
+	LIBNAME="$1"
+	TGT="$2"
+fi
+
+NAME=$(git config user.name)
+EMAIL=$(git config user.email)
+USER="${NAME} <${EMAIL}>"
+YEAR=$(date '+%Y')
+
+function cabal_file {
+	cat <<EOF
+name:             ${LIBNAME}
+version:          0.1.0.0
+-- synopsis:
+-- description:
+license:          BSD3
+license-file:     LICENSE
+author:           ${USER}
+maintainer:       ${USER}
+copyright:        ©${YEAR} ${NAME}
+-- category:
+build-type:       Simple
+cabal-version:    >= 1.12
+
+library
+--  exposed-modules:
+  ghc-options:         -Wall
+  build-depends:       base >=4.7 && <4.9
+  default-language:    Haskell2010
+  default-extensions:  OverloadedStrings,
+                       ScopedTypeVariables
+EOF
+}
+
+if [ "x${TGT}" = "x-" ]; then
+	cabal_file
+else
+	cabal_file >${TGT}
+fi