-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmain.go
41 lines (36 loc) · 1.19 KB
/
main.go
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
package main
import (
"flag"
"fmt"
"os"
"github.com/friends-of-hugo/contentful-export/extract"
"github.com/friends-of-hugo/contentful-export/read"
"github.com/friends-of-hugo/contentful-export/translate"
"github.com/friends-of-hugo/contentful-export/write"
)
func main() {
space := flag.String("space-id", os.Getenv("CONTENTFUL_API_SPACE"), "The contentful space id to export data from")
key := flag.String("api-key", os.Getenv("CONTENTFUL_API_KEY"), "The contentful delivery API access token")
config := flag.String("config-file", "extract-config.toml", "Path to the TOML config file to load for export config")
preview := flag.Bool("p", false, "Use contentful's preview API so that draft content is downloaded")
flag.Parse()
fmt.Println("Begin contentful export : ", *space)
extractor := extract.Extractor{
ReadConfig: read.ReadConfig{
UsePreview: *preview,
SpaceID: *space,
AccessToken: *key,
Locale: "en-US",
},
Getter: read.HttpGetter{},
TransConfig: translate.LoadConfig(*config),
WStore: write.FileStore{},
RStore: read.FileStore{},
}
err := extractor.ProcessAll()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("finished")
}
}