62 lines
839 B
Go
62 lines
839 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/alexflint/go-arg"
|
|
|
|
"git.zorchenhimer.com/zorchenhimer/go-fds"
|
|
)
|
|
|
|
type Arguments struct {
|
|
Input string `arg:"positional,required"`
|
|
|
|
Blocks bool `arg:"--blocks"`
|
|
}
|
|
|
|
|
|
func main() {
|
|
args := &Arguments{}
|
|
arg.MustParse(args)
|
|
|
|
err := run(args)
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func run(args *Arguments) error {
|
|
if args.Blocks {
|
|
file, err := os.Open(args.Input)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
defer file.Close()
|
|
|
|
blocks, err := fds.ReadRomBlocks(file, filepath.Ext(args.Input) == ".fds")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, block := range blocks {
|
|
fmt.Println(block.String())
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
rom, err := fds.ReadRomFile(args.Input)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Println(rom.Info())
|
|
|
|
return nil
|
|
}
|
|
|
|
|