-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathmain.go
73 lines (64 loc) · 2.21 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 (
"fmt"
"os"
"strings"
"github.com/NuruProgramming/Nuru/repl"
"github.com/NuruProgramming/Nuru/styles"
"github.com/charmbracelet/lipgloss"
)
var (
Title = styles.TitleStyle.
Render(`
█░░ █░█ █▀▀ █░█ ▄▀█ █▄█ ▄▀█ █▄░█ █░█ █▀█ █░█
█▄▄ █▄█ █▄█ █▀█ █▀█ ░█░ █▀█ █░▀█ █▄█ █▀▄ █▄█`)
Version = styles.VersionStyle.Render("v0.5.18")
Author = styles.AuthorStyle.Render("by Nuru Org")
NewLogo = lipgloss.JoinVertical(lipgloss.Center, Title, lipgloss.JoinHorizontal(lipgloss.Center, Author, " | ", Version))
Help = styles.HelpStyle.Italic(false).Render(fmt.Sprintf(`💡 Namna ya kutumia Nuru:
%s: Kuanza programu ya Nuru
%s: Kuendesha faili la Nuru
%s: Kusoma nyaraka za Nuru
%s: Kufahamu toleo la Nuru
`,
styles.HelpStyle.Bold(true).Render("nuru"),
styles.HelpStyle.Bold(true).Render("nuru jinaLaFile.nr"),
styles.HelpStyle.Bold(true).Render("nuru --nyaraka"),
styles.HelpStyle.Bold(true).Render("nuru --toleo")))
)
func main() {
args := os.Args
if len(args) < 2 {
help := styles.HelpStyle.Render("💡 Tumia exit() au toka() kuondoka")
fmt.Println(lipgloss.JoinVertical(lipgloss.Left, NewLogo, "\n", help))
repl.Start()
return
}
if len(args) == 2 {
switch args[1] {
case "msaada", "-msaada", "--msaada", "help", "-help", "--help", "-h":
fmt.Println(Help)
case "version", "-version", "--version", "-v", "v", "--toleo", "-toleo":
fmt.Println(NewLogo)
case "-docs", "--docs", "-nyaraka", "--nyaraka":
repl.Docs()
default:
file := args[1]
if strings.HasSuffix(file, "nr") || strings.HasSuffix(file, ".sw") {
contents, err := os.ReadFile(file)
if err != nil {
fmt.Println(styles.ErrorStyle.Render("Error: Nuru imeshindwa kusoma faili: ", args[1]))
os.Exit(1)
}
repl.Read(string(contents))
} else {
fmt.Println(styles.ErrorStyle.Render("'"+file+"'", "sii faili sahihi. Tumia faili la '.nr' au '.sw'"))
os.Exit(1)
}
}
} else {
fmt.Println(styles.ErrorStyle.Render("Error: Operesheni imeshindikana boss."))
fmt.Println(Help)
os.Exit(1)
}
}