Skip to content
This repository has been archived by the owner on Jan 2, 2024. It is now read-only.

Commit

Permalink
cmd/tier: accept --at flag for report (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany committed Jul 13, 2023
1 parent e550b72 commit eb35003
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/tier/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ Flags:
--clobber
Clobber any existing usage for the provided feature. If false, the
usage will be incremeneted by n.
--at
At specifies the time at which the usage occurred. If not provided,
the current time will be used. The time must be in seconds since the
epoch.
`,
"whois": `Usage:
Expand Down
10 changes: 10 additions & 0 deletions cmd/tier/tier.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ func runTier(cmd string, args []string) (err error) {
case "report":
fs := flag.NewFlagSet(cmd, flag.ExitOnError)
clobber := fs.Bool("clobber", false, "clobber existing value")
fat := fs.String("at", "", "sets the time of the usage event (unix seconds)")
if err := fs.Parse(args); err != nil {
return err
}
Expand All @@ -417,7 +418,16 @@ func runTier(cmd string, args []string) (err error) {
if err != nil {
return err
}
var at time.Time
if *fat != "" {
nsecs, err := strconv.ParseInt(*fat, 10, 64)
if err != nil {
return err
}
at = time.Unix(nsecs, 0)
}
return tc().ReportUsage(ctx, org, feature, n, &tier.ReportParams{
At: at,
Clobber: *clobber,
})
case "whoami":
Expand Down

0 comments on commit eb35003

Please sign in to comment.