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

Commit

Permalink
cmd/tier: add --clobber flag to report command (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmizerany committed Jan 26, 2023
1 parent d058cda commit 592b1a5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion cmd/tier/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,19 @@ If the --live flag is provided, your accounts live mode will be used.
`,
"report": `Usage:
tier [--live] report <org> <feature> <n>
tier [--live] report [flags] <org> <feature> <n>
Tier report reports that n units of feature were used by org to Stripe.
For a report of usage, see the ("tier limits") command.
If the --live flag is provided, your accounts live mode will be used.
Flags:
--clobber
Clobber any existing usage for the provided feature. If false, the
usage will be incremeneted by n.
`,
"whois": `Usage:
Expand Down
14 changes: 13 additions & 1 deletion cmd/tier/tier.go
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,15 @@ func runTier(cmd string, args []string) (err error) {
}
return nil
case "report":
fs := flag.NewFlagSet(cmd, flag.ExitOnError)
clobber := fs.Bool("clobber", false, "clobber existing value")
if err := fs.Parse(args); err != nil {
return err
}
if fs.NArg() == 0 {
return errUsage
}
args := fs.Args()
org, feature, sn := getArg(args, 0), getArg(args, 1), getArg(args, 2)
if org == "" || feature == "" || sn == "" {
return errUsage
Expand All @@ -397,7 +406,10 @@ func runTier(cmd string, args []string) (err error) {
if err != nil {
return err
}
return tc().Report(ctx, org, feature, n)
return tc().ReportUsage(ctx, org, feature, n, &tier.ReportParams{
At: time.Now(),
Clobber: *clobber,
})
case "whoami":
who, err := tc().WhoAmI(ctx)
if err != nil {
Expand Down

0 comments on commit 592b1a5

Please sign in to comment.