Cleanup
This commit is contained in:
parent
506b5af9d3
commit
f0fde4a5a9
4
main.go
4
main.go
@ -37,7 +37,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Fprintf(os.Stderr, "Usage: %s file_format input_file output_file\n\n", path.Base(os.Args[0]))
|
fmt.Fprintf(os.Stderr, "Usage: %s format input output\n\n", path.Base(os.Args[0]))
|
||||||
fmt.Fprintf(os.Stderr, "Parameters:\n")
|
fmt.Fprintf(os.Stderr, "Parameters:\n")
|
||||||
flag.PrintDefaults()
|
flag.PrintDefaults()
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ func outputJson(fileFormat, inputPath, outputDir string, flags int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
prettyJson := flag.Bool("prettyJson", false, "output prettified json")
|
prettyJson := flag.Bool("pretty", false, "output prettified json")
|
||||||
|
|
||||||
flag.Usage = usage
|
flag.Usage = usage
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
10
termmeta.go
10
termmeta.go
@ -75,12 +75,12 @@ func newTermMetaIndex(entries []termMetaEntry, entities map[string]string) termM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (index *termMetaDb) output(dir string, pretty bool) error {
|
func (db *termMetaDb) output(dir string, pretty bool) error {
|
||||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, err := marshalJson(index, pretty)
|
bytes, err := marshalJson(db, pretty)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -96,7 +96,7 @@ func (index *termMetaDb) output(dir string, pretty bool) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var entries [][]string
|
var entries [][]string
|
||||||
for _, e := range index.entries {
|
for _, e := range db.entries {
|
||||||
entries = append(
|
entries = append(
|
||||||
entries,
|
entries,
|
||||||
[]string{
|
[]string{
|
||||||
@ -212,6 +212,6 @@ func outputTermMetaJson(dir string, reader io.Reader, flags int) error {
|
|||||||
entries = append(entries, extractEdictTermMeta(jmdictEntry)...)
|
entries = append(entries, extractEdictTermMeta(jmdictEntry)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
index := newTermMetaIndex(entries, entities)
|
db := newTermMetaIndex(entries, entities)
|
||||||
return index.output(dir, flags&flagPrettyJson == flagPrettyJson)
|
return db.output(dir, flags&flagPrettyJson == flagPrettyJson)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user