From 52f839cd7de8e203ca7868a66dc7c1f1ae972d2f Mon Sep 17 00:00:00 2001 From: Dagen Brock Date: Sun, 1 Jan 2023 11:30:24 -0600 Subject: [PATCH] Improvements (#3) * bump for more formatter fixes (DUPE, woops) * Add `indent` option and improve cadius errors --- .gitignore | 4 ++++ README.md | 5 +++-- appy.yaml | 1 + core/diskbuilder.go | 10 +++++----- core/formatter.go | 5 +++++ core/project/project.go | 1 + go.mod | 2 +- go.sum | 6 ++---- testsrc/fmt.s | 3 +++ testsrc/fmt2.s | 27 +++++++++++++++++++++++++++ 10 files changed, 52 insertions(+), 12 deletions(-) create mode 100644 .gitignore create mode 100644 testsrc/fmt2.s diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5acfdfc --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# cadius disk files +*.2mg +# merlin assembly listings +*_output.txt \ No newline at end of file diff --git a/README.md b/README.md index d7c9061..e0a6a94 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,8 @@ Appy abstracts the tools away from a script mindset, and into a project mindset. Currently it uses an `appy.yaml` file in the current project directory. The format is as follows: ``` -assemble: [main.s, grafix.s, snd.s, a.s, b.s] # <--- list of files to assemble with Merlin +assemble: [main.s, grafix.s, snd.s, a.s, b.s] # <--- list of files to assemble with Merlin +indent: [c.s] # <--- additional files to indent when running `appy fmt` disks: # <--- define disks, can be more than one, handy for 140K + 800K - name: mydiskimage # <---- each disk has a name (ProDOS volume name) file: mydiskimage800.2mg # <---- each disk has a filename for the image it creates @@ -45,7 +46,7 @@ disks: # <--- define disks, can be more ``` ## User Overrides -What if your copy of Merlin32 (assembler) is in a different location than your teammates? You can set up local binary overrides with an `appy.user.yaml` file in the same directory. It allows the following 3 program settings: +What if your copy of Merlin32 (assembler) is in a different location than your teammate's? You can set up local binary overrides with an `appy.user.yaml` file in the same directory. It allows the following 3 program settings: ``` # local system settings/overrides programs: diff --git a/appy.yaml b/appy.yaml index 47f87ba..c32c619 100644 --- a/appy.yaml +++ b/appy.yaml @@ -1,4 +1,5 @@ assemble: [testsrc/sp.s, testsrc/pc.s, testsrc/fmt.s] +indent: [testsrc/fmt2.s] disks: - name: mydiskimage file: mydiskimage800.2mg diff --git a/core/diskbuilder.go b/core/diskbuilder.go index 4ea1e3f..f8fc684 100644 --- a/core/diskbuilder.go +++ b/core/diskbuilder.go @@ -6,14 +6,15 @@ import ( "os/exec" "github.com/digarok/appy/core/project" + "github.com/fatih/color" ) func CreateDisk(name string, file string, size string) { fmt.Printf("Creating Disk: \"%s\" -> %s \tSize: %s\n", name, file, size) - cmd := exec.Command(project.LocalConf.Programs.Cadius, "CREATEVOLUME", file, name, size) - err := cmd.Run() + out, err := exec.Command(project.LocalConf.Programs.Cadius, "CREATEVOLUME", file, name, size).Output() if err != nil { + color.Cyan(string(out)) log.Fatal(err) } } @@ -21,12 +22,11 @@ func CreateDisk(name string, file string, size string) { func AddFiles(disk project.Disk) { fmt.Printf("Add files to: \"%s\"\n", disk.Name) for _, file := range disk.Files { - // fmt.Printf("%s ADDFILE %s %s %s\n", CadiusPath, disk.File, file.Output, file.Input) fmt.Printf(" Adding file: -----> %s\n", file.Input) - cmd := exec.Command(project.LocalConf.Programs.Cadius, "ADDFILE", disk.File, file.Output, file.Input) - err := cmd.Run() + out, err := exec.Command(project.LocalConf.Programs.Cadius, "ADDFILE", disk.File, file.Output, file.Input).Output() if err != nil { + color.Cyan(string(out)) log.Fatal(err) } } diff --git a/core/formatter.go b/core/formatter.go index 09c5aaa..bc18ee9 100644 --- a/core/formatter.go +++ b/core/formatter.go @@ -14,6 +14,11 @@ func Format(args []string) { fmt.Printf("Formatting %v\n", filename) merlingo.FmtFile(filename) } + // format all indent files in appy.yaml + for _, filename := range project.AppyProj.Indent { + fmt.Printf("Formatting %v\n", filename) + merlingo.FmtFile(filename) + } } else { // format all assembly files in args for _, filename := range args { diff --git a/core/project/project.go b/core/project/project.go index 8ad3e82..3420792 100644 --- a/core/project/project.go +++ b/core/project/project.go @@ -13,6 +13,7 @@ type Project struct { name string Disks []Disk Assemble []string + Indent []string } type Disk struct { diff --git a/go.mod b/go.mod index 6250fc6..cd4fe97 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/digarok/appy go 1.16 require ( - github.com/digarok/merlingo v1.0.2 + github.com/digarok/merlingo v1.0.3 github.com/fatih/color v1.13.0 github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v1.1.3 diff --git a/go.sum b/go.sum index 2fb51c9..93f5dbd 100644 --- a/go.sum +++ b/go.sum @@ -37,10 +37,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/digarok/merlingo v1.0.1 h1:jAmUXvhQI+tzwlEjWEbclT1NZXZXef/P+ybFCTbdRUk= -github.com/digarok/merlingo v1.0.1/go.mod h1:rdReR6enl/63dfkssdM4xwg0gXw3j4QprK9e+e8mX9U= -github.com/digarok/merlingo v1.0.2 h1:Pgl3exZAMdyLk2ILztNAFht6h8BVAiq/h1KgPtgT4oo= -github.com/digarok/merlingo v1.0.2/go.mod h1:rdReR6enl/63dfkssdM4xwg0gXw3j4QprK9e+e8mX9U= +github.com/digarok/merlingo v1.0.3 h1:W0jtn8PZQsBlkpvfODFO38GSFx91uV4LXDhN1dkK62A= +github.com/digarok/merlingo v1.0.3/go.mod h1:rdReR6enl/63dfkssdM4xwg0gXw3j4QprK9e+e8mX9U= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= diff --git a/testsrc/fmt.s b/testsrc/fmt.s index 0a10a71..70a02af 100644 --- a/testsrc/fmt.s +++ b/testsrc/fmt.s @@ -22,3 +22,6 @@ HEXDEC mx %11 STA DEC8+2 STA DEC8+3 ReallyThisisaLoooooongLabelwith stal $e12000,y ; look at this long line + +* TABS.... +* $D5 $0008 sequence [Application Specific] diff --git a/testsrc/fmt2.s b/testsrc/fmt2.s new file mode 100644 index 0000000..70a02af --- /dev/null +++ b/testsrc/fmt2.s @@ -0,0 +1,27 @@ +* formatting test + org $300 ; start + +main nop + * what about this + + ; and this + + sta :jo+1 + + +:jo+1 lda $400 + lda $400 + rts + +** 24 (bit) hex to 8 (nibble) / 4 byte BCD +** 24 (bit) hex to +HEXDEC mx %11 + LDA #0 ; Ensure the result is clear + STA DEC8+0 + STA DEC8+1 + STA DEC8+2 + STA DEC8+3 +ReallyThisisaLoooooongLabelwith stal $e12000,y ; look at this long line + +* TABS.... +* $D5 $0008 sequence [Application Specific]