/
boid.io
73 lines (69 loc) · 2.47 KB
/
boid.io
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/usr/bin/env io
Importer addSearchPath("Boid")
Boid
BoidError
Range
opts := System args
opts removeFirst
opts first switch(
nil,
"boid -h" println,
"check",
envBoidDir := System getEnvironmentVariable("BOIDDIR")
if(envBoidDir isNil,
Boid fail("BOIDDIR environment variable not set"),
"BOIDDIR=#{envBoidDir}" interpolate println)
envIoImport := System getEnvironmentVariable("IOIMPORT")
if(envIoImport isNil,
Boid fail("IOIMPORT environment variable not set"),
"IOIMPORT=#{envIoImport}" interpolate println)
if(envIoImport split(":") contains(Boid ioDir path) not,
Boid fail("`#{Boid ioDir path}' not in IOIMPORT"))
if(System getEnvironmentVariable("PATH") split(":") contains(Boid binDir path) not,
Boid fail("`#{Boid binDir path}' not in PATH"))
if(Boid check not,
Boid fail("invalid setup, please run setup.io again"))
"ok" println,
"install",
packageSpec := opts second
if(packageSpec isNil, Boid fail("no package spec provided"))
e := try(Boid install(packageSpec))
e catch(BoidError, Boid fail("install failed: #{e error}" interpolate))
"package #{packageSpec} installed" interpolate println,
"uninstall",
packageSpec := opts second
if(packageSpec isNil, Boid fail("no package spec provided"))
e := try(Boid uninstall(packageSpec))
e catch(BoidError, Boid fail("uninstall failed: #{e error}" interpolate))
"package #{packageSpec} uninstalled" interpolate println,
"list",
Boid listPackages,
"env",
envCmd := opts second
if(envCmd isNil, envCmd = "list")
envCmd switch(
"list",
Boid Environment directories foreach(d,
if(d at(".active"), "* " print)
d name println),
"active",
Boid Environment directories select(d, d at(".active")) first name println,
"use",
envName := opts third
if(envName isNil, Boid fail("no environment name provided"))
e := try(Boid Environment use(envName))
e catch(BoidError, Boid fail(e error))
"switched environment to #{envName}" interpolate println,
"create",
envName := opts third
if(envName isNil, Boid fail("no environment name provided"))
e := try(Boid Environment create(envName))
e catch(BoidError, Boid fail(e error))
"#{envName} environment created" interpolate println,
"destroy",
envName := opts third
if(envName isNil, Boid fail("no environment name provided"))
e := try(Boid Environment destroy(envName))
e catch(BoidError, Boid fail(e error))
"#{envName} environment destroyed" interpolate println))
Boid cleanup