From f8cf3fea035d7f0ad0287166c3a5016777acf5ad Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 10 Nov 2019 15:50:56 +0100 Subject: cli: add bridge token show --- commands/bridge_token_rm.go | 4 ++-- commands/bridge_token_show.go | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 commands/bridge_token_show.go (limited to 'commands') diff --git a/commands/bridge_token_rm.go b/commands/bridge_token_rm.go index 1f4ca4e8..a73fbb91 100644 --- a/commands/bridge_token_rm.go +++ b/commands/bridge_token_rm.go @@ -24,8 +24,8 @@ func runBridgeTokenRm(cmd *cobra.Command, args []string) error { } var bridgeTokenRmCmd = &cobra.Command{ - Use: "rm", - Short: "Remove token by Id.", + Use: "rm ", + Short: "Remove a token.", PreRunE: loadRepo, RunE: runBridgeTokenRm, Args: cobra.ExactArgs(1), diff --git a/commands/bridge_token_show.go b/commands/bridge_token_show.go new file mode 100644 index 00000000..2d2e824d --- /dev/null +++ b/commands/bridge_token_show.go @@ -0,0 +1,36 @@ +package commands + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/MichaelMure/git-bug/bridge/core" +) + +func runBridgeTokenShow(cmd *cobra.Command, args []string) error { + token, err := core.LoadTokenPrefix(repo, args[0]) + if err != nil { + return err + } + + fmt.Printf("Id: %s\n", token.ID()) + fmt.Printf("Value: %s\n", token.Value) + fmt.Printf("Target: %s\n", token.Target) + fmt.Printf("Creation: %s\n", token.CreateTime.Format(time.RFC822)) + + return nil +} + +var bridgeTokenShowCmd = &cobra.Command{ + Use: "show", + Short: "Display a token.", + PreRunE: loadRepo, + RunE: runBridgeTokenShow, + Args: cobra.ExactArgs(1), +} + +func init() { + bridgeTokenCmd.AddCommand(bridgeTokenShowCmd) +} -- cgit