some error handling in project library

This commit is contained in:
Sameer Rahmani 2010-12-28 17:28:58 +03:30
parent 8d95c57a5f
commit 8b12e2f335
2 changed files with 20 additions and 1 deletions

4
TODO
View File

@ -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
* 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

View File

@ -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))
)
)