Skip to content

Commit 3f52200

Browse files
Merge branch 'AvicennaJr:main' into main
2 parents c52bb1d + 9a9bd40 commit 3f52200

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=0.5.0-alpha
1+
VERSION=0.5.1
22

33
build_linux:
44
@echo 'building linux binary...'

main.go

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,36 @@ func main() {
3838
help := styles.HelpStyle.Render("💡 Tumia exit() au toka() kuondoka")
3939
fmt.Println(lipgloss.JoinVertical(lipgloss.Left, NewLogo, "\n", help))
4040
repl.Start()
41-
os.Exit(0)
41+
return
4242
}
4343

4444
if len(args) == 2 {
45-
4645
switch args[1] {
4746
case "msaada", "-msaada", "--msaada", "help", "-help", "--help", "-h":
4847
fmt.Println(Help)
49-
os.Exit(0)
5048
case "version", "-version", "--version", "-v", "v", "--toleo", "-toleo":
5149
fmt.Println(NewLogo)
52-
os.Exit(0)
5350
case "-docs", "--docs", "-nyaraka", "--nyaraka":
5451
repl.Docs()
55-
os.Exit(0)
56-
}
52+
default:
53+
file := args[1]
5754

58-
file := args[1]
55+
if strings.HasSuffix(file, "nr") || strings.HasSuffix(file, ".sw") {
56+
contents, err := os.ReadFile(file)
57+
if err != nil {
58+
fmt.Println(styles.ErrorStyle.Render("Error: Nuru imeshindwa kusoma faili: ", args[1]))
59+
os.Exit(1)
60+
}
5961

60-
if strings.HasSuffix(file, "nr") || strings.HasSuffix(file, ".sw") {
61-
contents, err := os.ReadFile(file)
62-
if err != nil {
63-
fmt.Println(styles.ErrorStyle.Render("Error: Nuru imeshindwa kusoma faili: ", args[1]))
64-
os.Exit(0)
62+
repl.Read(string(contents))
63+
} else {
64+
fmt.Println(styles.ErrorStyle.Render("'"+file+"'", "sii faili sahihi. Tumia faili la '.nr' au '.sw'"))
65+
os.Exit(1)
6566
}
66-
67-
repl.Read(string(contents))
68-
} else {
69-
fmt.Println(styles.ErrorStyle.Render("'"+file+"'", "sii faili sahihi. Tumia faili la '.nr' au '.sw'"))
70-
os.Exit(0)
7167
}
72-
7368
} else {
7469
fmt.Println(styles.ErrorStyle.Render("Error: Operesheni imeshindikana boss."))
7570
fmt.Println(Help)
76-
os.Exit(0)
71+
os.Exit(1)
7772
}
7873
}

0 commit comments

Comments
 (0)