From 317dbd4030272b477d24a22b718b405776eee06b Mon Sep 17 00:00:00 2001 From: Lukas Braun <koomi@moshbit.net> Date: Tue, 3 Oct 2017 01:41:20 +0200 Subject: [PATCH] Add set-count subcommand --- goatherd.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/goatherd.go b/goatherd.go index 0941c0f..f6f3ed5 100644 --- a/goatherd.go +++ b/goatherd.go @@ -13,6 +13,7 @@ import ( "log" "net" "os" + "strconv" "strings" "sync" "time" @@ -537,6 +538,16 @@ func main() { user := args[0] secret := args[1] create_user(user, secret) + case "set-counter": + if len(args) != 2 { + log.Fatalf("set-counter: Invalid number of arguments: %v (expecting <username> <counter>)\n", len(args)) + } + user := args[0] + counter, err := strconv.ParseUint(args[1], 0, 64) + err_fatal(err) + if err = set_count(db, user, counter); err != nil { + err_fatal(err) + } case "serve": fs := flag.NewFlagSet("serve", flag.ExitOnError) flag_addr := fs.String("addr", "", "Address to listen on. (default 127.0.0.1:9999)") -- GitLab