Skip to content

allow users to rename template file names. #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions quickproject.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
(defvar *include-copyright* nil ; This gives default behavior.
"Include a copyright notice at the top of files.")

(defvar *file-renamer* nil
"Function to rename files.")

(defun pathname-project-name (pathname)
"Return a project name based on PATHNAME by taking the last element
in the pathname-directory list. E.g. returns \"awesome-project\" for
Expand Down Expand Up @@ -72,7 +75,7 @@ marker is the string \"\(#|\" and the template end marker is the string
(flet ((rewrite-template (pathname)
(let* ((relative-namestring
(enough-namestring pathname template-directory))
(target-pathname (template-pathname->output-name
(target-pathname (funcall *file-renamer*
(merge-pathnames relative-namestring
target-directory)))
(if-exists if-exists))
Expand Down Expand Up @@ -130,7 +133,8 @@ marker is the string \"\(#|\" and the template end marker is the string
((:author *author*) *author*)
((:license *license*) *license*)
(name (pathname-project-name pathname) name-provided-p)
((:include-copyright *include-copyright*) *include-copyright*))
((:include-copyright *include-copyright*) *include-copyright*)
(file-renamer #'template-pathname->output-name file-renamer-p))
"Create a project skeleton for NAME in PATHNAME. If DEPENDS-ON is provided,
it is used as the asdf defsystem depends-on list."
(check-type *depends-on* list)
Expand All @@ -142,7 +146,8 @@ it is used as the asdf defsystem depends-on list."
(setf name (pathname-project-name pathname))))
(ensure-directories-exist pathname)
(let ((*default-pathname-defaults* (truename pathname))
(*name* name))
(*name* name)
(*file-renamer* file-renamer))
(let (c)
(restart-case (handler-case
(rewrite-templates *template-directory*
Expand Down