main: add -d option to delete cache
This commit is contained in:
parent
9ffbe09d8d
commit
fa1faeaa9f
1 changed files with 10 additions and 1 deletions
11
main.go
11
main.go
|
|
@ -19,18 +19,27 @@ const version = "0-pre"
|
||||||
|
|
||||||
var addr *string
|
var addr *string
|
||||||
var port *uint16
|
var port *uint16
|
||||||
|
var deleteAndExit *bool
|
||||||
var regenerate *bool
|
var regenerate *bool
|
||||||
var showVersion *bool
|
var showVersion *bool
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
addr = getopt.String('a', "0.0.0.0")
|
addr = getopt.String('a', "0.0.0.0")
|
||||||
port = getopt.Uint16('p', 8000)
|
port = getopt.Uint16('p', 8000)
|
||||||
|
deleteAndExit = getopt.Bool('d')
|
||||||
regenerate = getopt.Bool('r')
|
regenerate = getopt.Bool('r')
|
||||||
showVersion = getopt.Bool('V')
|
showVersion = getopt.Bool('V')
|
||||||
if err := getopt.Getopt(nil); err != nil {
|
if err := getopt.Getopt(nil); err != nil {
|
||||||
util.Die(err.Error())
|
util.Die(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if *deleteAndExit {
|
||||||
|
err := os.RemoveAll(musicindex.TempDir)
|
||||||
|
if err != nil {
|
||||||
|
util.Die("cannot remove %s: %s", musicindex.TempDir, err.Error())
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
if *showVersion {
|
if *showVersion {
|
||||||
fmt.Printf("records %s\n", version)
|
fmt.Printf("records %s\n", version)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
@ -38,7 +47,7 @@ func main() {
|
||||||
|
|
||||||
args := getopt.Args()
|
args := getopt.Args()
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
fmt.Fprintf(os.Stderr, "usage: %s [-rV] [-a address] [-p port] directory\n", os.Args[0])
|
fmt.Fprintf(os.Stderr, "usage: %s [-drV] [-a address] [-p port] directory\n", os.Args[0])
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue