Appy/core/formatter.go

35 lines
811 B
Go
Raw Normal View History

2022-07-04 00:50:56 +00:00
package core
import (
"fmt"
"github.com/digarok/appy/core/project"
"github.com/digarok/merlingo"
)
func Format(args []string) {
2023-02-16 03:33:12 +00:00
// merlingo.Status()
if project.AppyProj.FormatFlags != "" {
merlingo.ParseModeline(project.AppyProj.FormatFlags)
}
2022-07-04 00:50:56 +00:00
if len(args) == 0 {
// format all assembly files in appy.yaml
for _, filename := range project.AppyProj.Assemble {
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)
}
2022-07-04 00:50:56 +00:00
} else {
// format all assembly files in args
for _, filename := range args {
fmt.Printf("Formatting %v\n", filename)
merlingo.FmtFile(filename)
}
}
2023-02-16 03:33:12 +00:00
// merlingo.Status()
2022-07-04 00:50:56 +00:00
}