summaryrefslogtreecommitdiff
path: root/shelf/cmd/sum/main.go
blob: 441a70610210f89ba6f0fe27cdef3b77b7e5814f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main

import (
	"flag"
	"log"
	"os"

	"go.jknobloc.com/x/shelf"
)

func main() {
	rootPath := flag.String("root", ".shelf", "Path to the shelf")
	ignorePath := flag.String("ignore", ".shelfignore", "Path to .shelfignore")

	flag.Parse()

	shelf.Root = *rootPath

	ignore, _ := os.ReadFile(*ignorePath)

	var sum shelf.Sum

	if s, err := shelf.Index(ignore); err != nil {
		log.Fatal(err)
	} else {
		sum = s
	}

	if err := shelf.Serialize(sum, os.Stdout); err != nil {
		log.Fatal(err)
	}
}