diff --git a/main.go b/main.go index f293872..67793f8 100644 --- a/main.go +++ b/main.go @@ -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)