M6: serve and export modes, packaging

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
lucioandClaude Opus 5.5 committed 2026-11-04 04:58:48 -08:00
1 parent 45105d292f
commit 00ee2a6d12
29 files changed
+1294 -75

No files matched your search

+29 -9
View File
@@ -10,19 +10,28 @@ import (
"os/signal"
"syscall"
"github.com/luciochen233/luphoto/internal/app"
"github.com/luciochen233/luphoto/internal/build"
"github.com/luciochen233/luphoto/internal/config"
)
var version = "dev"
const usage = `usage: luphoto [-config path] <command>
commands:
build process albums once and publish a new build
serve build, watch and serve over HTTP
serve build, watch and serve over HTTP on server.listen
export build into the output folder and keep watching
run serve or export, as server.mode says
version print the version
flags:
-config path config file (default /etc/luphoto/config.toml; a missing file means all defaults)
signals:
SIGHUP re-read the config and rebuild
SIGINT/SIGTERM stop gracefully
`
func main() {
@@ -62,7 +71,10 @@ func run(args []string) int {
return 2
}
switch command {
case "build", "serve", "export":
case "version":
fmt.Println("luphoto " + version)
return 0
case "build", "serve", "export", "run":
default:
fmt.Fprintf(os.Stderr, "luphoto: unknown command %q\n\n%s", command, usage)
return 2
@@ -80,15 +92,23 @@ func run(args []string) int {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
summary, err := build.Run(ctx, cfg, logger)
if err != nil {
logger.Printf("luphoto: build failed: %v", err)
return 1
if command == "build" {
summary, err := build.Run(ctx, cfg, logger)
if err != nil {
logger.Printf("luphoto: build failed: %v", err)
return 1
}
logger.Print(summary.String())
return 0
}
logger.Print(summary.String())
if command != "build" {
logger.Printf("luphoto %s: not implemented yet (arrives in milestone M6); built once, exiting", command)
mode := command
if mode == "run" {
mode = cfg.Server.Mode
}
logger.Printf("luphoto %s: %s mode, config %s", version, mode, *configPath)
if err := app.Run(ctx, mode, *configPath, cfg, logger); err != nil {
logger.Printf("luphoto: %v", err)
return 1
}
return 0