From 7e15843425d9f8967b0219076de6507fb9a4882b Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 22 May 2024 10:56:43 -0500 Subject: [PATCH] correct column generator --- pkgs/oizys/oizys-go/pkg/oizys.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkgs/oizys/oizys-go/pkg/oizys.go b/pkgs/oizys/oizys-go/pkg/oizys.go index ce21c0b..a34677a 100644 --- a/pkgs/oizys/oizys-go/pkg/oizys.go +++ b/pkgs/oizys/oizys-go/pkg/oizys.go @@ -117,7 +117,7 @@ func ellipsis(s string, maxLen int) string { func (p *packages) show(verbose bool) { p.summary() - if !verbose { + if !verbose || (len(p.names) == 0) { return } @@ -127,7 +127,7 @@ func (p *packages) show(verbose bool) { fmt.Printf("%s\n", strings.Repeat("-", w)) for i, pkg := range pkgs { fmt.Printf("%-*s", p.pad, pkg) - if i%nCols == 0 { + if (i+1)%nCols == 0 { fmt.Println() } } @@ -189,17 +189,18 @@ func parseDryRun(buf string) (*packages, *packages) { } } - if len(parts[0]) + len(parts[1]) == 0 { + if len(parts[0])+len(parts[1]) == 0 { log.Println("no changes...") log.Println("or I failed to parse it into the expected number of parts") log.Fatalln("failed to parse nix build --dry-run output") } - return parsePackages(parts[0], "packages to build"), parsePackages(parts[1], "packages to fetch") + return parsePackages(parts[0], "packages to build"), + parsePackages(parts[1], "packages to fetch") } func showDryRunResult(nixOutput string, verbose bool) { - toBuild, toFetch := parseDryRun(nixOutput) + toBuild, toFetch := parseDryRun(nixOutput) toBuild.show(verbose) toFetch.show(verbose) } @@ -258,7 +259,6 @@ func (o *Oizys) CacheBuild(rest ...string) { runCommand(cmd) } - func (o *Oizys) CheckFlake() { if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) { log.Fatalln("path to flake:", o.flake, "does not exist")