Simplify usage.
This commit is contained in:
parent
86022818da
commit
98cd890766
1 changed files with 11 additions and 9 deletions
|
@ -2,7 +2,6 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -14,20 +13,23 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gpxFile := flag.String("gpx", "", "Path to GPX file")
|
log.SetFlags(0)
|
||||||
dirName := flag.String("dir", "", "Directory to scan for GPX files")
|
if len(os.Args) != 2 {
|
||||||
flag.Parse()
|
log.Fatal("Usage: %s GPX_FILE_OR_DIRECTORY")
|
||||||
if (*gpxFile == "" && *dirName == "") || (*gpxFile != "" && *dirName != "") {
|
}
|
||||||
log.Fatal("exactly one of --dir or --gpx is required")
|
inFile := os.Args[1]
|
||||||
|
info, err := os.Stat(inFile)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
gs, err := placenames.NewGPXSummarizer()
|
gs, err := placenames.NewGPXSummarizer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
if *gpxFile != "" {
|
if info.IsDir() {
|
||||||
err = summarizeSingleFile(gs, *gpxFile)
|
err = summarizeDirectory(gs, inFile)
|
||||||
} else {
|
} else {
|
||||||
err = summarizeDirectory(gs, *dirName)
|
err = summarizeSingleFile(gs, inFile)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
|
Loading…
Reference in a new issue