commit
a8c1f942c3
3 changed files with 49 additions and 0 deletions
@ -0,0 +1,17 @@
|
||||
# modules |
||||
|
||||
Support utilities for working with [slope](https://git.rawtext.club/slope-lang/slope) modules. |
||||
|
||||
## Usage |
||||
|
||||
Currently this module only exposes a single function, `mod-exists?`, which allows callers to identify whether or not a given module is available. |
||||
|
||||
``` slope |
||||
(load-mod "modules") |
||||
;; (mod-exists? [module-name: string]) => bool |
||||
|
||||
(mod-exists? "csv" "flag") ; => #t |
||||
``` |
||||
|
||||
`mod-exists?` can take any number of module names as strings. It will only return true if all of the given modules are available. |
||||
|
@ -0,0 +1,22 @@
|
||||
;;; |
||||
;;; modules - Module management utilities |
||||
;;; Author: sloum |
||||
;;; Version: 0.1.0 |
||||
;;; |
||||
|
||||
;; Takes any number of strings and verifies if the |
||||
;; given modules are available to the current runtime |
||||
(define mod-exists? (lambda (...) |
||||
(equal? 0 |
||||
(length |
||||
(filter |
||||
(lambda (b) (equal? #f b)) |
||||
(map |
||||
(lambda (v) |
||||
(or |
||||
(path-exists? (path-join (mod-path) v)) |
||||
(path-exists? (path-join "/usr/local/lib/slope/modules" v)))) |
||||
...)))))) |
||||
|
||||
(define _USAGE [ |
||||
["mod-exists?" "(mod-exists? [module-name: string...]) => bool\n\nChecks if the given module is installed on the system and available to the current runtime. `#t` will only be returned if all of the given modules are present (it functions like `and`)"]]) |
Loading…
Reference in new issue