-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhot.red
More file actions
45 lines (39 loc) · 1.06 KB
/
hot.red
File metadata and controls
45 lines (39 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Red []
CURRENT-CMD: to-block system/script/args
HOTLIB-PATH: to-red-file rejoin [get-env either system/platform == 'Windows ["USERPROFILE"]["HOME"] %/.hot/]
unless exists? HOTLIB-PATH [make-dir/deep HOTLIB-PATH]
foreach file read HOTLIB-PATH [
do/args rejoin [HOTLIB-PATH file] system/options/path
]
;
; Commands
;
cmd: context [
install: func [url [url!]][
file: last split-path url
write rejoin [HOTLIB-PATH file] read url
]
uninstall: func ['cmd-context [word!]][
delete to-red-file rejoin [HOTLIB-PATH cmd-context ".red"]
]
]
help: does [
fn-name-rule: charset [#"a" - #"z" #"-"]
foreach [fn _] to-block do cmd [
if parse to-string fn [some fn-name-rule] [
print to-string rejoin ["cmd/" fn]
]
]
foreach file read HOTLIB-PATH [
ctx: replace to-string file ".red" ""
foreach [fn _] to-block do to-word ctx [
if parse to-string fn [some fn-name-rule] [
print to-string rejoin [ctx "/" fn]
]
]
]
]
;
; Main
;
do CURRENT-CMD