Implement better CLI using kingpin.

master
Icedream 2017-09-07 12:00:57 +02:00
parent dddef0d558
commit 5a8760ae23
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
1 changed files with 11 additions and 1 deletions

12
main.go
View File

@ -7,6 +7,8 @@ import (
"io/ioutil"
"log"
"os"
"gopkg.in/alecthomas/kingpin.v2"
)
const (
@ -20,6 +22,12 @@ const (
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 (
DefaultPageSize = 1024
)
@ -200,7 +208,9 @@ func (p *Processor) ExpectEnd() {
}
func main() {
inputFilePath := os.Args[1]
kingpin.MustParse(app.Parse(os.Args[1:]))
inputFilePath := *argInput
// Open BF source code
input, err := ioutil.ReadFile(inputFilePath)