aboutsummaryrefslogtreecommitdiffstats
path: root/commands/bridge_token.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/bridge_token.go')
-rw-r--r--commands/bridge_token.go26
1 files changed, 5 insertions, 21 deletions
diff --git a/commands/bridge_token.go b/commands/bridge_token.go
index 7467691e..b9e2d49f 100644
--- a/commands/bridge_token.go
+++ b/commands/bridge_token.go
@@ -6,27 +6,14 @@ import (
"github.com/spf13/cobra"
- "github.com/MichaelMure/git-bug/bridge/core"
- "github.com/MichaelMure/git-bug/cache"
- "github.com/MichaelMure/git-bug/util/colors"
- "github.com/MichaelMure/git-bug/util/interrupt"
text "github.com/MichaelMure/go-term-text"
-)
-var (
- bridgeTokenLocal bool
- bridgeTokenGlobal bool
+ "github.com/MichaelMure/git-bug/bridge/core"
+ "github.com/MichaelMure/git-bug/util/colors"
)
func runTokenBridge(cmd *cobra.Command, args []string) error {
- backend, err := cache.NewRepoCache(repo)
- if err != nil {
- return err
- }
- defer backend.Close()
- interrupt.RegisterCleaner(backend.Close)
-
- tokens, err := core.ListTokens(backend)
+ tokens, err := core.ListTokens(repo)
if err != nil {
return err
}
@@ -43,13 +30,12 @@ func runTokenBridge(cmd *cobra.Command, args []string) error {
}
func printToken(token *core.Token) {
- idFmt := text.LeftPadMaxLine(token.ID.Human(), 7, 0)
valueFmt := text.LeftPadMaxLine(token.Value, 15, 0)
targetFmt := text.LeftPadMaxLine(token.Target, 7, 0)
createTimeFmt := text.LeftPadMaxLine(token.CreateTime.Format(time.RFC822), 20, 0)
fmt.Printf("%s %s %s %s\n",
- idFmt,
+ token.ID().Human(),
colors.Magenta(targetFmt),
valueFmt,
createTimeFmt,
@@ -58,7 +44,7 @@ func printToken(token *core.Token) {
var bridgeTokenCmd = &cobra.Command{
Use: "token",
- Short: "List all stored tokens.",
+ Short: "List all known tokens.",
PreRunE: loadRepo,
RunE: runTokenBridge,
Args: cobra.NoArgs,
@@ -66,7 +52,5 @@ var bridgeTokenCmd = &cobra.Command{
func init() {
bridgeCmd.AddCommand(bridgeTokenCmd)
- bridgeTokenCmd.Flags().BoolVarP(&bridgeTokenLocal, "local", "l", false, "")
- bridgeTokenCmd.Flags().BoolVarP(&bridgeTokenGlobal, "global", "g", false, "")
bridgeTokenCmd.Flags().SortFlags = false
}