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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
// codeberg-sqlite mirrors a Forgejo repository's issues and pull requests
// into a local SQLite database, so they can be queried with SQL instead of a
// web UI.
//
// It has one subcommand:
//
// ingest Fetch issues, pull requests, comments and reviews over the
// Forgejo API and write them to SQLite. Incremental: subsequent
// runs fetch only what changed.
//
// There is no server and no search command. The output is a database with a
// documented schema; the query tool is sqlite3. See codeberg-sqlite(1) for
// the schema and worked example queries.
//
// Typical use:
//
// codeberg-sqlite ingest --db flohmarkt.db --repo flohmarkt/flohmarkt
// sqlite3 flohmarkt.db "SELECT number, title FROM issue WHERE state='open'"
package main
import (
"fmt"
"os"
)
func main() {
if len(os.Args) < 2 {
usage()
os.Exit(2)
}
var err error
switch os.Args[1] {
case "ingest":
err = runIngest(os.Args[2:])
case "-h", "--help", "help":
usage()
return
default:
fmt.Fprintf(os.Stderr, "codeberg-sqlite: unknown subcommand %q\n", os.Args[1])
usage()
os.Exit(2)
}
if err != nil {
fmt.Fprintf(os.Stderr, "codeberg-sqlite: %v\n", err)
os.Exit(1)
}
}
func usage() {
fmt.Fprint(os.Stderr, `codeberg-sqlite — mirror a Forgejo repo's issues and PRs into SQLite
usage:
codeberg-sqlite ingest --db <path> --repo <owner/name>
[--host <host>] [--token <tok>]
[--full] [--no-reviews] [--timeout <duration>]
The API token may also be supplied as CODEBERG_TOKEN, which keeps it out of
the process table.
`)
}
|