From 3b52234d84dba23fd5f4276ce6b1c2a5ebf49c29 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Tue, 25 Nov 2014 13:33:07 +0000 Subject: [PATCH] the --book-dir option is mandatory --- cmd/liber/liber.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/liber/liber.go b/cmd/liber/liber.go index eb2738c..f423492 100644 --- a/cmd/liber/liber.go +++ b/cmd/liber/liber.go @@ -193,9 +193,9 @@ func b2i(b bool) int { } func expandTilde(path string) string { - if path[:2] == "~/" { + if strings.HasPrefix(path, "~/") { curUser, _ := user.Current() - return filepath.Join(curUser.HomeDir, path[2:len(path)]) + return filepath.Join(curUser.HomeDir, strings.TrimPrefix(path, "~/")) } return path } @@ -207,8 +207,8 @@ func main() { if nset != 1 { log.Fatal("Must specify one of --update, --sync, --search or --http-server") } - if *update && *bookDir == "" { - log.Fatal("Must specify --book-dir with --update") + if *bookDir == "" { + log.Fatal("Must specify --book-dir") } dbdir := expandTilde(*databaseDir) -- GitLab