From 8b12e2f3359cc86fe50850f16218aae05cc37fee Mon Sep 17 00:00:00 2001 From: Sameer Rahmani Date: Tue, 28 Dec 2010 17:28:58 +0330 Subject: [PATCH] some error handling in project library --- TODO | 4 +++- src/lib/project.el | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 06d26d4..f32ea08 100644 --- a/TODO +++ b/TODO @@ -3,4 +3,6 @@ * Review license templates * Build the debian folder nad required files for deb packages * Escape project name for a unix name "shell-quote-argument" -* Add a config file for user to put his/her configuration there \ No newline at end of file +* Add a config file for user to put his/her configuration there +* Allow templates file to store in subdirectories so new project can + have subdirectories \ No newline at end of file diff --git a/src/lib/project.el b/src/lib/project.el index e38dd08..475b86b 100644 --- a/src/lib/project.el +++ b/src/lib/project.el @@ -28,10 +28,12 @@ ;; Project name (setq project-name (read-string "Project Name: ")) + (if (string= project-name "") (error "Project name must not be emty")) ;; Shit IDE use unix-project-name for dealing with project OS activity stuffs (setq unix-project-name (downcase (replace-regexp-in-string " " "_" project-name))) ;; if specified directory does not exists, shit will make it (setq project-path (read-directory-name "Project Path: " nil nil nil unix-project-name)) + (log project-path) (if (not (file-exists-p project-path)) (progn (mkdir project-path) @@ -103,4 +105,19 @@ (setq data (replace-regexp-in-string "::license::" license-data data)) ) ) + +(defun project/write-dest-file (FILE DATA) + "Write the rendered DATA to its destenation file in project source tree. +destenation file address created from template FILE name. + FILE : (string) Address of corresponding template + DATA : (string) Rendered data" + + (let (curfile destfile) + (setq curfile (split-string FILE "/")) + (nbutlast curfile) + (setq curfile (replace-regexp-in-string "__project__" unix-project-name curfile)) + (setq curfile (replace-regexp-in-string "\.tmpl" "" curfile)) + (setq destfile (concat project-path curfile)) + ) +) \ No newline at end of file