-
Notifications
You must be signed in to change notification settings - Fork 0
/
tools4clj.go
85 lines (72 loc) · 1.63 KB
/
tools4clj.go
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
74
75
76
77
78
79
80
81
82
83
84
85
/*************************************************************************
* Copyright (c) 2019 Tasos Mamaloukos.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution.
*
* The Eclipse Public License is available at
* https://www.eclipse.org/org/documents/epl-v10.html
*
*************************************************************************/
package tools4clj
import (
"fmt"
"os"
)
func init() {
var err error
tools4CljDir, err = getTools4CljPath()
if err != nil {
panic(err)
}
javaPath, err = getJavaPath()
if err != nil {
panic(err)
}
toolsCp, err = getToolsCp(tools4CljDir)
if err != nil {
panic(err)
}
execCp, err = getExecCp(tools4CljDir)
if err != nil {
panic(err)
}
}
// RunClojure runs clojure using the official clojure tools
func RunClojure(osArgs []string) {
runClojure(osArgs, false)
}
// RunClj runs clojure within a readline wrapper
func RunClj(osArgs []string) {
runClojure(osArgs, true)
}
func runClojure(osArgs []string, cljRun bool) {
// download official clojure tools
err := getClojureTools(tools4CljDir)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
var opts allOpts
// read and set command line options
exit, err := read(&opts, osArgs, cljRun)
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
} else if exit {
os.Exit(0)
}
if opts.Main.Help {
fmt.Print(usage + "\n")
return
}
// use command line options
err = use(&opts)
if err != nil {
if opts.Clj.Verbose {
fmt.Fprintln(os.Stderr, err)
}
os.Exit(1)
}
}