@@ -38,41 +38,36 @@ func main() {
38
38
help := styles .HelpStyle .Render ("💡 Tumia exit() au toka() kuondoka" )
39
39
fmt .Println (lipgloss .JoinVertical (lipgloss .Left , NewLogo , "\n " , help ))
40
40
repl .Start ()
41
- os . Exit ( 0 )
41
+ return
42
42
}
43
43
44
44
if len (args ) == 2 {
45
-
46
45
switch args [1 ] {
47
46
case "msaada" , "-msaada" , "--msaada" , "help" , "-help" , "--help" , "-h" :
48
47
fmt .Println (Help )
49
- os .Exit (0 )
50
48
case "version" , "-version" , "--version" , "-v" , "v" , "--toleo" , "-toleo" :
51
49
fmt .Println (NewLogo )
52
- os .Exit (0 )
53
50
case "-docs" , "--docs" , "-nyaraka" , "--nyaraka" :
54
51
repl .Docs ()
55
- os . Exit ( 0 )
56
- }
52
+ default :
53
+ file := args [ 1 ]
57
54
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
+ }
59
61
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 )
65
66
}
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 )
71
67
}
72
-
73
68
} else {
74
69
fmt .Println (styles .ErrorStyle .Render ("Error: Operesheni imeshindikana boss." ))
75
70
fmt .Println (Help )
76
- os .Exit (0 )
71
+ os .Exit (1 )
77
72
}
78
73
}
0 commit comments