Simplify view and edit command (#184)

* Simplify the view command

* Simplify the edit command

* Migrate number-only book names

* Run migration

* Simplify remove

* Print note info when adding, editing, or removing

* Disallow users from editing or removing already removed notes
This commit is contained in:
Sung Won Cho 2019-05-18 16:52:12 +10:00 committed by GitHub
commit f526124243
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 447 additions and 113 deletions

View file

@ -26,6 +26,7 @@ import (
"net/http"
"os"
"path/filepath"
"regexp"
"strings"
"syscall"
@ -248,3 +249,15 @@ func CopyFile(src, dest string) error {
return nil
}
// regexNumber is a regex that matches a string that looks like an integer
var regexNumber = regexp.MustCompile(`^\d+$`)
// IsNumber checks if the given string is in the form of a number
func IsNumber(s string) bool {
if s == "" {
return false
}
return regexNumber.MatchString(s)
}