Implement better CLI using kingpin.
parent
dddef0d558
commit
5a8760ae23
12
main.go
12
main.go
|
@ -7,6 +7,8 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
"gopkg.in/alecthomas/kingpin.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -20,6 +22,12 @@ const (
|
||||||
InstLoopEnd = ']'
|
InstLoopEnd = ']'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
app = kingpin.New("gobfy", "Yet another interpreter for Brainfuck programs.")
|
||||||
|
|
||||||
|
argInput = app.Arg("input", "The source file of the program to execute.").Required().ExistingFile()
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
DefaultPageSize = 1024
|
DefaultPageSize = 1024
|
||||||
)
|
)
|
||||||
|
@ -200,7 +208,9 @@ func (p *Processor) ExpectEnd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
inputFilePath := os.Args[1]
|
kingpin.MustParse(app.Parse(os.Args[1:]))
|
||||||
|
|
||||||
|
inputFilePath := *argInput
|
||||||
|
|
||||||
// Open BF source code
|
// Open BF source code
|
||||||
input, err := ioutil.ReadFile(inputFilePath)
|
input, err := ioutil.ReadFile(inputFilePath)
|
||||||
|
|
Loading…
Reference in New Issue