correct column generator

This commit is contained in:
Daylin Morgan 2024-05-22 10:56:43 -05:00
parent 2c6a0ca733
commit 7e15843425
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -117,7 +117,7 @@ func ellipsis(s string, maxLen int) string {
func (p *packages) show(verbose bool) { func (p *packages) show(verbose bool) {
p.summary() p.summary()
if !verbose { if !verbose || (len(p.names) == 0) {
return return
} }
@ -127,7 +127,7 @@ func (p *packages) show(verbose bool) {
fmt.Printf("%s\n", strings.Repeat("-", w)) fmt.Printf("%s\n", strings.Repeat("-", w))
for i, pkg := range pkgs { for i, pkg := range pkgs {
fmt.Printf("%-*s", p.pad, pkg) fmt.Printf("%-*s", p.pad, pkg)
if i%nCols == 0 { if (i+1)%nCols == 0 {
fmt.Println() fmt.Println()
} }
} }
@ -195,7 +195,8 @@ func parseDryRun(buf string) (*packages, *packages) {
log.Fatalln("failed to parse nix build --dry-run output") 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) { func showDryRunResult(nixOutput string, verbose bool) {
@ -258,7 +259,6 @@ func (o *Oizys) CacheBuild(rest ...string) {
runCommand(cmd) runCommand(cmd)
} }
func (o *Oizys) CheckFlake() { func (o *Oizys) CheckFlake() {
if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) { if _, err := os.Stat(o.flake); errors.Is(err, fs.ErrNotExist) {
log.Fatalln("path to flake:", o.flake, "does not exist") log.Fatalln("path to flake:", o.flake, "does not exist")