work on command line improvements
This commit is contained in:
parent
a78a5a4a4a
commit
c55f513e68
10
main.go
10
main.go
@ -57,16 +57,16 @@ func exportDb(inputPath, outputDir, format, title string, stride int, pretty boo
|
|||||||
}
|
}
|
||||||
|
|
||||||
func serveDb(serveDir string, port int) error {
|
func serveDb(serveDir string, port int) error {
|
||||||
log.Printf("starting dictionary server on port %d...\n", port)
|
log.Printf("starting dictionary server on port %d for extension...\n", port)
|
||||||
return http.ListenAndServe(fmt.Sprintf(":%d", port), http.FileServer(http.Dir(serveDir)))
|
return http.ListenAndServe(fmt.Sprintf(":%d", port), http.FileServer(http.Dir(serveDir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
format = flag.String("format", "", "dictionary format [edict|enamdict|kanjidic|epwing]")
|
format = flag.String("format", "", "dictionary format [edict|enamdict|kanjidic|epwing]")
|
||||||
port = flag.Int("port", 9876, "port to serve JSON on")
|
port = flag.Int("port", 9876, "port to serve dictionary JSON on")
|
||||||
pretty = flag.Bool("pretty", false, "output prettified JSON")
|
pretty = flag.Bool("pretty", false, "output prettified dictionary JSON")
|
||||||
serve = flag.Bool("serve", false, "serve JSON over HTTP")
|
serve = flag.Bool("serve", false, "serve dictionary JSON for extension")
|
||||||
stride = flag.Int("stride", 10000, "dictionary bank stride")
|
stride = flag.Int("stride", 10000, "dictionary bank stride")
|
||||||
title = flag.String("title", "", "dictionary title")
|
title = flag.String("title", "", "dictionary title")
|
||||||
)
|
)
|
||||||
@ -95,6 +95,8 @@ func main() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*serve = true
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := exportDb(inputPath, outputDir, *format, *title, *stride, *pretty); err != nil {
|
if err := exportDb(inputPath, outputDir, *format, *title, *stride, *pretty); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user