v0.5.0: manifests, filters, logging, docs
pipeline / build (push) Has been cancelled
pipeline / test (push) Has been cancelled

This commit is contained in:
Ein Anderssono
2026-06-15 00:00:06 +02:00
parent 3d3c4a4742
commit 2e73d01b40
33 changed files with 7238 additions and 512 deletions
+1000 -115
View File
File diff suppressed because it is too large Load Diff
+3 -23
View File
@@ -1,10 +1,9 @@
//go:build !test
package main
import (
"os"
"os/signal"
"sync/atomic"
"syscall"
"gitea.k3s.k0.nu/tools/photocli/internal/photos"
)
@@ -12,24 +11,5 @@ import (
var version = "dev"
func main() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
done := make(chan struct{})
var rc atomic.Int32
go func() {
rc.Store(int32(run(os.Args[1:], os.Stdout, os.Stderr, photos.DefaultBridge)))
close(done)
}()
select {
case <-done:
case <-sigCh:
photos.DefaultBridge.Cancel()
os.Stderr.Write([]byte("\nreceived signal, finishing current file...\n"))
<-done
}
os.Exit(int(rc.Load()))
os.Exit(runMain(os.Args[1:], os.Stdout, os.Stderr, photos.DefaultBridge))
}
+5
View File
@@ -0,0 +1,5 @@
//go:build test
package main
var version = "dev"
+3037 -80
View File
File diff suppressed because it is too large Load Diff
-18
View File
@@ -14,7 +14,6 @@ type progressBar struct {
width int
termH int
start time.Time
errors []string
workers int
footerLines int
scrollSet bool
@@ -94,12 +93,6 @@ func (p *progressBar) updateWorkerProgress(i int, progress float64, bytesDone, b
}
}
func (p *progressBar) addError(filename string, err error) {
p.mu.Lock()
defer p.mu.Unlock()
p.errors = append(p.errors, fmt.Sprintf(" \u274c %s: %v", filename, err))
}
func (p *progressBar) logCompleted(line string) {
p.mu.Lock()
defer p.mu.Unlock()
@@ -168,13 +161,6 @@ func (p *progressBar) clear() {
p.scrollSet = false
}
func (p *progressBar) flushErrors() {
for _, e := range p.errors {
fmt.Fprintln(p.w, e)
}
p.errors = nil
}
func renderWorkerLine(ws workerSlot, width int) string {
if width <= 0 {
width = 80
@@ -300,9 +286,6 @@ func renderBar(pct, barWidth int) string {
if fullBlocks < barWidth {
fracs := []string{"", "\u258f", "\u258e", "\u258d", "\u258c", "\u258b", "\u258a", "\u2589"}
idx := int(partial * 8)
if idx > 7 {
idx = 7
}
if idx > 0 {
sb.WriteString(fracs[idx])
fullBlocks++
@@ -347,7 +330,6 @@ func truncateOrPad(s string, width int) string {
return string(runes[:i]) + "..."
}
}
return s
}
return s + strings.Repeat(" ", width-rw)
}
+33
View File
@@ -0,0 +1,33 @@
package main
import (
"io"
"os"
"sync/atomic"
"gitea.k3s.k0.nu/tools/photocli/internal/photos"
)
func runMain(args []string, stdout, stderr *os.File, bridge photos.Bridge) int {
return runMainWithSignal(args, stdout, stderr, bridge, defaultSignalChan())
}
func runMainWithSignal(args []string, stdout *os.File, stderr io.Writer, bridge photos.Bridge, sigCh <-chan struct{}) int {
done := make(chan struct{})
var rc atomic.Int32
go func() {
rc.Store(int32(run(args, stdout, stderr, bridge)))
close(done)
}()
select {
case <-done:
case <-sigCh:
bridge.Cancel()
stderr.Write([]byte("\nreceived signal, finishing current file...\n"))
<-done
}
return int(rc.Load())
}
+20
View File
@@ -0,0 +1,20 @@
//go:build !test
package main
import (
"os"
"os/signal"
"syscall"
)
func defaultSignalChan() <-chan struct{} {
ch := make(chan struct{})
go func() {
sig := make(chan os.Signal, 1)
signal.Notify(sig, syscall.SIGINT, syscall.SIGTERM)
<-sig
close(ch)
}()
return ch
}
+8
View File
@@ -0,0 +1,8 @@
//go:build test
package main
func defaultSignalChan() <-chan struct{} {
ch := make(chan struct{})
return ch
}