-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
73 lines (52 loc) · 1.15 KB
/
main.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
package main
import (
"bufio"
"flag"
"fmt"
"io/ioutil"
"os"
"strings"
"github.com/PersoSirEduard/kode/kode"
)
const (
VERSION = "alpha 0.5.0"
)
func main() {
path := flag.String("run", "main.kd", "Path to the Kode file.")
showVersion := flag.Bool("version", false, "Show the current version of Kode.")
StdIn := flag.Bool("runStdIn", false, "Read from stdin.")
flag.Parse()
if *StdIn {
in := bufio.NewScanner(os.Stdin)
code := ""
for in.Scan() {
bytes := in.Bytes()
txt := string(bytes)
if strings.ReplaceAll(txt, " ", "") == "exit" {
break
}
if txt != "" {
code += txt + "\n"
}
}
err := kode.Run(code)
if err != nil {
fmt.Println(err.Error())
}
os.Exit(1)
}
if *showVersion {
fmt.Println("Kode version: " + VERSION)
fmt.Println("Created by Eduard A. and Frédéric J.")
fmt.Println("Make sure to check out the GitHub repository: https://github.com/PersoSirEduard/Kode")
return
}
code, err := ioutil.ReadFile(*path)
if err != nil {
println("Error: Could not find and read the file \"" + *path + "\".")
}
err = kode.Run(string(code))
if err != nil {
println(err.Error())
}
}