-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
46 lines (37 loc) · 1.29 KB
/
Copy pathmain.go
File metadata and controls
46 lines (37 loc) · 1.29 KB
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
// csvlang is a simple programming language that can be used to manipulate CSV files.
//
// The main.go file is the entry point of the application. It reads the file path from the command line arguments and evaluates the code in the file.
package main
import (
"flag"
"fmt"
"github.com/Rishabh570/csvlang/repl"
)
func main() {
// user, err := user.Current()
// if err != nil {
// panic(err)
// }
// fmt.Printf("Hello %s! This is the Monkey programming language!\n", user.Username)
// fmt.Printf("Feel free to type in commands\n")
// repl.Start(os.Stdin, os.Stdout)
// Define a string flag called "path" with a default value of "" and a brief description.
filePath := flag.String("path", "", "Path to the file")
// Parse the command line flags.
flag.Parse()
// Use the file path after parsing. If it's empty, it means the flag was not provided.
if *filePath == "" {
fmt.Println("Please provide a file path using the -path flag.")
return
}
// file path must have .csl extension
if len(*filePath) < 4 || (*filePath)[len(*filePath)-4:] != ".csl" {
fmt.Println("File path must have .csl extension")
return
}
// Output the provided file path.
fmt.Printf("File path: %s\n", *filePath)
// repl.StartFile(*filePath)
repl.StartFileAllAtOnce(*filePath)
// repl.StartLexer(*filePath)
}