Peter Kurfer
9ea9a8f658
Some checks failed
Go build / build (push) Failing after 1m58s
- setup ent scheme - add command to create users - document API - add helpers to create migrations - add command to run migrations - add basic compose file
31 lines
503 B
Go
31 lines
503 B
Go
package cli
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"github.com/alecthomas/kong"
|
|
)
|
|
|
|
var _ kong.MapperValue = (*TokenClaim)(nil)
|
|
|
|
type TokenClaim struct {
|
|
Key, Value string
|
|
}
|
|
|
|
func (t *TokenClaim) Decode(ctx *kong.DecodeContext) error {
|
|
token, err := ctx.Scan.PopValue("claim")
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
split := strings.Split(token.String(), "=")
|
|
if len(split) != 2 {
|
|
return fmt.Errorf("cannot split into key value pair: %s", token.String())
|
|
}
|
|
|
|
t.Key = split[0]
|
|
t.Value = split[1]
|
|
|
|
return nil
|
|
}
|