aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-11-10 15:50:56 +0100
committerMichael Muré <batolettre@gmail.com>2019-11-10 15:50:56 +0100
commitf8cf3fea035d7f0ad0287166c3a5016777acf5ad (patch)
treee077b7a22a966ba03077c76bcb35373feb5e90c5
parente2445edcb99ed0aa7fcd40fe7484d71e73367334 (diff)
downloadgit-bug-f8cf3fea035d7f0ad0287166c3a5016777acf5ad.tar.gz
cli: add bridge token show
-rw-r--r--bridge/core/token.go2
-rw-r--r--commands/bridge_token_rm.go4
-rw-r--r--commands/bridge_token_show.go36
-rw-r--r--doc/man/git-bug-bridge-token-rm.16
-rw-r--r--doc/man/git-bug-bridge-token-show.129
-rw-r--r--doc/man/git-bug-bridge-token.12
-rw-r--r--doc/md/git-bug_bridge_token.md3
-rw-r--r--doc/md/git-bug_bridge_token_rm.md6
-rw-r--r--doc/md/git-bug_bridge_token_show.md22
-rw-r--r--misc/bash_completion/git-bug21
-rw-r--r--misc/powershell_completion/git-bug6
-rw-r--r--misc/zsh_completion/git-bug10
12 files changed, 134 insertions, 13 deletions
diff --git a/bridge/core/token.go b/bridge/core/token.go
index b9d68c0b..2ceabca2 100644
--- a/bridge/core/token.go
+++ b/bridge/core/token.go
@@ -55,7 +55,7 @@ func (t *Token) Validate() error {
if t.Target == "" {
return fmt.Errorf("missing target")
}
- if t.CreateTime.IsZero() {
+ if t.CreateTime.IsZero() || t.CreateTime.Equal(time.Time{}) {
return fmt.Errorf("missing creation time")
}
if !TargetExist(t.Target) {
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 <id>",
+ 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)
+}
diff --git a/doc/man/git-bug-bridge-token-rm.1 b/doc/man/git-bug-bridge-token-rm.1
index 5c5a16a6..217d938d 100644
--- a/doc/man/git-bug-bridge-token-rm.1
+++ b/doc/man/git-bug-bridge-token-rm.1
@@ -5,17 +5,17 @@
.SH NAME
.PP
-git\-bug\-bridge\-token\-rm \- Remove token by Id.
+git\-bug\-bridge\-token\-rm \- Remove a token.
.SH SYNOPSIS
.PP
-\fBgit\-bug bridge token rm [flags]\fP
+\fBgit\-bug bridge token rm <id> [flags]\fP
.SH DESCRIPTION
.PP
-Remove token by Id.
+Remove a token.
.SH OPTIONS
diff --git a/doc/man/git-bug-bridge-token-show.1 b/doc/man/git-bug-bridge-token-show.1
new file mode 100644
index 00000000..f40b5024
--- /dev/null
+++ b/doc/man/git-bug-bridge-token-show.1
@@ -0,0 +1,29 @@
+.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" ""
+.nh
+.ad l
+
+
+.SH NAME
+.PP
+git\-bug\-bridge\-token\-show \- Display a token.
+
+
+.SH SYNOPSIS
+.PP
+\fBgit\-bug bridge token show [flags]\fP
+
+
+.SH DESCRIPTION
+.PP
+Display a token.
+
+
+.SH OPTIONS
+.PP
+\fB\-h\fP, \fB\-\-help\fP[=false]
+ help for show
+
+
+.SH SEE ALSO
+.PP
+\fBgit\-bug\-bridge\-token(1)\fP
diff --git a/doc/man/git-bug-bridge-token.1 b/doc/man/git-bug-bridge-token.1
index d377556f..f229bf76 100644
--- a/doc/man/git-bug-bridge-token.1
+++ b/doc/man/git-bug-bridge-token.1
@@ -26,4 +26,4 @@ List all known tokens.
.SH SEE ALSO
.PP
-\fBgit\-bug\-bridge(1)\fP, \fBgit\-bug\-bridge\-token\-add(1)\fP, \fBgit\-bug\-bridge\-token\-rm(1)\fP
+\fBgit\-bug\-bridge(1)\fP, \fBgit\-bug\-bridge\-token\-add(1)\fP, \fBgit\-bug\-bridge\-token\-rm(1)\fP, \fBgit\-bug\-bridge\-token\-show(1)\fP
diff --git a/doc/md/git-bug_bridge_token.md b/doc/md/git-bug_bridge_token.md
index e263e291..14663784 100644
--- a/doc/md/git-bug_bridge_token.md
+++ b/doc/md/git-bug_bridge_token.md
@@ -20,5 +20,6 @@ git-bug bridge token [flags]
* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers.
* [git-bug bridge token add](git-bug_bridge_token_add.md) - Store a new token
-* [git-bug bridge token rm](git-bug_bridge_token_rm.md) - Remove token by Id.
+* [git-bug bridge token rm](git-bug_bridge_token_rm.md) - Remove a token.
+* [git-bug bridge token show](git-bug_bridge_token_show.md) - Display a token.
diff --git a/doc/md/git-bug_bridge_token_rm.md b/doc/md/git-bug_bridge_token_rm.md
index f8c5fcc2..534406f4 100644
--- a/doc/md/git-bug_bridge_token_rm.md
+++ b/doc/md/git-bug_bridge_token_rm.md
@@ -1,13 +1,13 @@
## git-bug bridge token rm
-Remove token by Id.
+Remove a token.
### Synopsis
-Remove token by Id.
+Remove a token.
```
-git-bug bridge token rm [flags]
+git-bug bridge token rm <id> [flags]
```
### Options
diff --git a/doc/md/git-bug_bridge_token_show.md b/doc/md/git-bug_bridge_token_show.md
new file mode 100644
index 00000000..80439617
--- /dev/null
+++ b/doc/md/git-bug_bridge_token_show.md
@@ -0,0 +1,22 @@
+## git-bug bridge token show
+
+Display a token.
+
+### Synopsis
+
+Display a token.
+
+```
+git-bug bridge token show [flags]
+```
+
+### Options
+
+```
+ -h, --help help for show
+```
+
+### SEE ALSO
+
+* [git-bug bridge token](git-bug_bridge_token.md) - List all known tokens.
+
diff --git a/misc/bash_completion/git-bug b/misc/bash_completion/git-bug
index 28924d1c..e8126b8f 100644
--- a/misc/bash_completion/git-bug
+++ b/misc/bash_completion/git-bug
@@ -444,6 +444,26 @@ _git-bug_bridge_token_rm()
noun_aliases=()
}
+_git-bug_bridge_token_show()
+{
+ last_command="git-bug_bridge_token_show"
+
+ command_aliases=()
+
+ commands=()
+
+ flags=()
+ two_word_flags=()
+ local_nonpersistent_flags=()
+ flags_with_completion=()
+ flags_completion=()
+
+
+ must_have_one_flag=()
+ must_have_one_noun=()
+ noun_aliases=()
+}
+
_git-bug_bridge_token()
{
last_command="git-bug_bridge_token"
@@ -453,6 +473,7 @@ _git-bug_bridge_token()
commands=()
commands+=("add")
commands+=("rm")
+ commands+=("show")
flags=()
two_word_flags=()
diff --git a/misc/powershell_completion/git-bug b/misc/powershell_completion/git-bug
index 094fa254..6a7bf0c3 100644
--- a/misc/powershell_completion/git-bug
+++ b/misc/powershell_completion/git-bug
@@ -86,7 +86,8 @@ Register-ArgumentCompleter -Native -CommandName 'git-bug' -ScriptBlock {
}
'git-bug;bridge;token' {
[CompletionResult]::new('add', 'add', [CompletionResultType]::ParameterValue, 'Store a new token')
- [CompletionResult]::new('rm', 'rm', [CompletionResultType]::ParameterValue, 'Remove token by Id.')
+ [CompletionResult]::new('rm', 'rm', [CompletionResultType]::ParameterValue, 'Remove a token.')
+ [CompletionResult]::new('show', 'show', [CompletionResultType]::ParameterValue, 'Display a token.')
break
}
'git-bug;bridge;token;add' {
@@ -97,6 +98,9 @@ Register-ArgumentCompleter -Native -CommandName 'git-bug' -ScriptBlock {
'git-bug;bridge;token;rm' {
break
}
+ 'git-bug;bridge;token;show' {
+ break
+ }
'git-bug;commands' {
[CompletionResult]::new('-p', 'p', [CompletionResultType]::ParameterName, 'Output the command description as well as Markdown compatible comment')
[CompletionResult]::new('--pretty', 'pretty', [CompletionResultType]::ParameterName, 'Output the command description as well as Markdown compatible comment')
diff --git a/misc/zsh_completion/git-bug b/misc/zsh_completion/git-bug
index 7f5f6231..f0ff7edf 100644
--- a/misc/zsh_completion/git-bug
+++ b/misc/zsh_completion/git-bug
@@ -180,7 +180,8 @@ function _git-bug_bridge_token {
cmnds)
commands=(
"add:Store a new token"
- "rm:Remove token by Id."
+ "rm:Remove a token."
+ "show:Display a token."
)
_describe "command" commands
;;
@@ -193,6 +194,9 @@ function _git-bug_bridge_token {
rm)
_git-bug_bridge_token_rm
;;
+ show)
+ _git-bug_bridge_token_show
+ ;;
esac
}
@@ -205,6 +209,10 @@ function _git-bug_bridge_token_rm {
_arguments
}
+function _git-bug_bridge_token_show {
+ _arguments
+}
+
function _git-bug_commands {
_arguments \
'(-p --pretty)'{-p,--pretty}'[Output the command description as well as Markdown compatible comment]'