2020-02-18 03:57:51 +01:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-09-17 18:25:09 +02:00
|
|
|
"gitea.com/jolheiser/sip/config"
|
2020-05-07 03:09:31 +02:00
|
|
|
|
2020-02-18 03:57:51 +01:00
|
|
|
"github.com/urfave/cli/v2"
|
2020-02-27 03:53:11 +01:00
|
|
|
"go.jolheiser.com/beaver"
|
|
|
|
"go.jolheiser.com/beaver/color"
|
2020-02-18 03:57:51 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var Tokens = cli.Command{
|
|
|
|
Name: "tokens",
|
|
|
|
Aliases: []string{"token"},
|
|
|
|
Usage: "Manage access tokens",
|
|
|
|
Action: doTokenList,
|
|
|
|
Subcommands: []*cli.Command{
|
|
|
|
&TokensAdd,
|
|
|
|
&TokensRemove,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-09-17 18:25:09 +02:00
|
|
|
func doTokenList(_ *cli.Context) error {
|
2020-02-18 06:27:52 +01:00
|
|
|
if len(config.Tokens) == 0 {
|
2020-02-27 03:53:11 +01:00
|
|
|
beaver.Errorf("No tokens found! Add one with %s", color.FgMagenta.Format("sip token create"))
|
2020-02-18 06:27:52 +01:00
|
|
|
}
|
2020-02-18 03:57:51 +01:00
|
|
|
for idx, token := range config.Tokens {
|
|
|
|
beaver.Infof("%d. %s (%s)", idx+1, token.Name, token.URL)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|