Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Facility for loading commands from known directory. Sample 'pwd' command added.
- Loading branch information
Sanel Zukan
committed
Sep 29, 2010
1 parent
92586fa
commit 1bb224b
Showing
6 changed files
with
72 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
(defcommand pwd | ||
"Print current directory." | ||
[] | ||
(.getCanonicalPath (java.io.File. "."))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
;; vim:ft=lisp:ts=3:sw=3:expandtab | ||
(ns hubris.command-dir | ||
"Code for loading commands from specific directory." | ||
(:gen-class)) | ||
|
||
(defn load-dir [fd dir ext] | ||
(doseq [i (.list fd)] | ||
(let [full-path (str dir | ||
java.io.File/separator | ||
i)] | ||
(when (.endsWith i ext) | ||
(printf "Loading %s...\n" full-path) | ||
|
||
;; so changes are kept localy | ||
(binding [*ns* *ns*] | ||
(in-ns 'hubris.builtin) | ||
(load-file full-path) | ||
) ) ) ) ) | ||
|
||
(defn load-all | ||
"Load all files with .clj extension from given directory | ||
and evaluate each of them." | ||
[dir] | ||
(let [fd (new java.io.File dir)] | ||
(if (.exists fd) | ||
(load-dir fd dir ".clj") | ||
(printf "'%s' is not readable. hubris is started with only builtin commands\n" dir) | ||
) ) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,4 +62,4 @@ | |
(if on | ||
(clojure.main/main) | ||
(init-plain-repl) | ||
)) | ||
) ) |