silent mode fixed

This commit is contained in:
Timon Ringwald 2022-08-17 19:48:36 +02:00
parent cb1105d4f6
commit cd24640118
2 changed files with 32 additions and 8 deletions

8
config.go Normal file
View File

@ -0,0 +1,8 @@
package main
type Config struct {
OS []string `json:"os"`
Arch []string `json:"arch"`
NoCompress bool `json:"no_compress"`
NumThreads int `json:"num_threads"`
}

16
init.go
View File

@ -16,43 +16,59 @@ func Init() {
ModulePath, err = filepath.Abs(flag.Arg(0))
if err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, "determining module path failed")
}
os.Exit(1)
}
*OutputDir, err = filepath.Abs(*OutputDir)
if err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, "determining output path failed")
}
os.Exit(1)
}
if _, err := exec.LookPath("go"); err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, "go not found in PATH. compilation not possible")
}
os.Exit(1)
}
if err := FillCompileConfigs(); err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, fmt.Errorf("target architectures could not be determined: %w", err))
}
os.Exit(1)
}
if _, err := os.Stat(filepath.Join(ModulePath, "go.mod")); errors.Is(err, os.ErrNotExist) {
if !*Silent {
ColorError.Fprintf(os.Stderr, "no Go module found at '%s'\n", ModulePath)
}
os.Exit(1)
}
if err := DetermineProjectName(); err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, fmt.Errorf("project name could not be determined: %w", err))
}
os.Exit(1)
}
if err := os.MkdirAll(*OutputDir, 0744); err != nil {
if !*Silent {
ColorError.Fprintln(os.Stderr, fmt.Errorf("output folder '%s' could not be made: %w", *OutputDir, err))
}
os.Exit(1)
}
if err := CheckDirWritable(*OutputDir); err != nil {
if !*Silent {
ColorError.Fprintf(os.Stderr, "output folder '%s' has insufficient permissions\n", *OutputDir)
}
os.Exit(1)
}