基本的に怠Diary

学習ログを残したい

GDD && プロジェクト作成スクリプト(bash)

G(GabrieDropOut)D(Driven)D(Design)

略してGDDD。

お前駆動開発ってどういう意味か知ってるか?

アニメ流しながら作業できたのはガヴリールドロップアウトだけでした。

ただのBGMじゃねえか。


毎回毎回毎回毎回自分で作るの辛いのでシェルスクリプトで作ることにした。

#!/bin/bash

echo -n "プロジェクト名:"
read pjname

pjpath="./${pjname}"

mkdir "${pjpath}"

mkdir "${pjpath}/src" "${pjpath}/t"

sharp='#'

echo -e $(cat <<EOS
;;
(in-package :cl-user)\n
(defpackage $pjname\n
  (:use :cl))\n
EOS
) > "${pjpath}/package.lisp"

echo -e $(cat <<EOS
;;

(require \'asdf)\n
\n
(in-package :cl-user)\n
(defpackage $pjname-asd\n
  (:use :cl :asdf))\n
(in-package :$pjname-asd)\n
\n
(defsystem :$pjname\n
  :version "1.0.0"\n
  :author "wasu"\n
  :license "MIT"\n
  :components ((:file "package")\n
               (:module "src" :components ((:file "$pjname")))))\n

EOS
) > "${pjpath}/${pjname}.asd"

echo -e $(cat <<EOS
;;
(require \'asdf)\n
\n
(in-package :cl-user)\n
(defpackage $pjname-test-asd\n
  (:use :cl :asdf))\n
(in-package :$pjname-test-asd)\n
\n
(defsystem $pjname-test\n
  :depends-on (:$pjname)\n
  :version "1.0.0"\n
  :author "wasu"\n
  :license "MIT"\n
  :components ((:module "t" :components ((:file "$pjname-test"))))\n
  :perform (load-op :after (op c) (asdf:clear-system c)))\n

EOS
) > "${pjpath}/${pjname}-test.asd"

echo -e $(cat <<EOS
(in-package $sharp:$pjname)
EOS
) > "${pjpath}/src/${pjname}.lisp"

echo -e $(cat <<EOS
(in-package :cl-user)\n
(defpackage $pjname-test\n
  (:use :cl :prove :$pjname))\n
(in-package $sharp:$pjname-test)\n
EOS
) > "${pjpath}/t/${pjname}-test.lisp"

sharpP='#P'
echo -e $(cat <<EOF
#|-*- mode:lisp -*-|#\n
(in-package :cl-user)\n
(defpackage :lake.user\n
  (:use :cl :lake :cl-syntax)\n
  (:shadowing-import-from :lake\n
                          :directory))\n
(in-package :lake.user)\n
\n
(use-syntax :interpol)\n
;;; here follow your tasks...\n

(task "test" ()\n
      (ql:quickload :prove)\n
      (load $sharpP"$pjname.asd")\n
      (load $sharpP"$pjname-test.asd")\n
      (asdf:test-system :$pjname-test))\n
EOF
) > "${pjpath}/Lakefile"



や'などの特殊文字が辛かった(こなみ

いろいろ調整した末に完成。

二時間悩んだな。

これで直下に申し訳程度のプロジェクト(笑)ができる。

Lispで作れ感すごい。