forked from refaktor/rye
-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.rye
55 lines (46 loc) · 1.25 KB
/
builder.rye
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
46
47
48
49
50
51
52
53
54
55
with Rye {
.info { Descr: "A script for building Rye instances in declarative way" Author: "JM" } ,
.needs { os } ,
.args { "build" { block! } "ls" opt { string! } "help" } ,
.usage {
"rye build { sqlite telegram }"
"rye build help"
"rye build ls"
"rye build ls sql"
}
}
CORE-MODULES: { "..." }
MODULES: {
sqlite { "github.com/mattn/go-sqlite3" }
telegram { "github.com/go-telegram-bot-api/telegram-bot-api" }
}
Rye .get-args-rye :args -> 1 |switch {
build { build-rye 2 <- args }
help { show-help 2 <- args }
ls { list-modules 2 <- args }
}
build-rye: fn1 {
.vars { cant-build: false }
.add* CORE-MODULES
|for {
.either-with { .find MODULES } {
.add* "go get " .pass { print "getting module:" } .print .cmd .print
} {
.add* "can't find module: " |print , cant-build: true
}
}
^if cant-build { print "Can't build" }
cmd "rye build"
}
show-help: does {
print "This is a simple utility to build Rye binaries"
print "Use > ryeb build { list of modules } to build a binary you need."
}
list-modules: fn { str } {
MODULES .for { .to-string |when { .contains str } { .print } }
}
; missing
; * Rye header functions ... add at least dummy ones
; * get-args-rye
; * function add that is equivalent of +
; * either-with , if-with (or when)