Appy/core/diskbuilder.go
Dagen Brock 52f839cd7d
Improvements (#3)
* bump for more formatter fixes (DUPE, woops)

* Add `indent` option and improve cadius errors
2023-01-01 11:30:24 -06:00

41 lines
921 B
Go

package core
import (
"fmt"
"log"
"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)
out, err := exec.Command(project.LocalConf.Programs.Cadius, "CREATEVOLUME", file, name, size).Output()
if err != nil {
color.Cyan(string(out))
log.Fatal(err)
}
}
func AddFiles(disk project.Disk) {
fmt.Printf("Add files to: \"%s\"\n", disk.Name)
for _, file := range disk.Files {
fmt.Printf(" Adding file: -----> %s\n", file.Input)
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)
}
}
}
func BuildDisk() {
for _, disk := range project.AppyProj.Disks {
CreateDisk(disk.Name, disk.File, disk.Size)
AddFiles(disk)
}
}