diff --git a/commands/bridge_token.go b/commands/bridge_auth.go similarity index 51% rename from commands/bridge_token.go rename to commands/bridge_auth.go index b9e2d49fc28ccc2a42dd3293ddce7ff9a52bd318..e7fce1bd5c1251a78989b942c13830929d6d9ca3 100644 --- a/commands/bridge_token.go +++ b/commands/bridge_auth.go @@ -2,7 +2,6 @@ package commands import ( "fmt" - "time" "github.com/spf13/cobra" @@ -12,7 +11,7 @@ import ( "github.com/MichaelMure/git-bug/util/colors" ) -func runTokenBridge(cmd *cobra.Command, args []string) error { +func runBridgeAuth(cmd *cobra.Command, args []string) error { tokens, err := core.ListTokens(repo) if err != nil { return err @@ -30,27 +29,25 @@ func runTokenBridge(cmd *cobra.Command, args []string) error { } func printToken(token *core.Token) { - valueFmt := text.LeftPadMaxLine(token.Value, 15, 0) - targetFmt := text.LeftPadMaxLine(token.Target, 7, 0) - createTimeFmt := text.LeftPadMaxLine(token.CreateTime.Format(time.RFC822), 20, 0) + targetFmt := text.LeftPadMaxLine(token.Target, 10, 0) fmt.Printf("%s %s %s %s\n", - token.ID().Human(), - colors.Magenta(targetFmt), - valueFmt, - createTimeFmt, + colors.Cyan(token.ID().Human()), + colors.Yellow(targetFmt), + colors.Magenta("token"), + token.Value, ) } -var bridgeTokenCmd = &cobra.Command{ - Use: "token", - Short: "List all known tokens.", +var bridgeAuthCmd = &cobra.Command{ + Use: "auth", + Short: "List all known bridge authentication credentials.", PreRunE: loadRepo, - RunE: runTokenBridge, + RunE: runBridgeAuth, Args: cobra.NoArgs, } func init() { - bridgeCmd.AddCommand(bridgeTokenCmd) - bridgeTokenCmd.Flags().SortFlags = false + bridgeCmd.AddCommand(bridgeAuthCmd) + bridgeAuthCmd.Flags().SortFlags = false } diff --git a/commands/bridge_token_add.go b/commands/bridge_auth_add.go similarity index 70% rename from commands/bridge_token_add.go rename to commands/bridge_auth_add.go index d2c697fa16bd2cc5e3b246228431b6fe60e136b7..ae2c4dbc3c844ea88c2c9a4af201848d593c334e 100644 --- a/commands/bridge_token_add.go +++ b/commands/bridge_auth_add.go @@ -15,17 +15,17 @@ import ( ) var ( - bridgeTokenTarget string + bridgeAuthAddTokenTarget string ) func runBridgeTokenAdd(cmd *cobra.Command, args []string) error { var value string - if bridgeTokenTarget == "" { - return fmt.Errorf("token target is required") + if bridgeAuthAddTokenTarget == "" { + return fmt.Errorf("auth target is required") } - if !core.TargetExist(bridgeTokenTarget) { + if !core.TargetExist(bridgeAuthAddTokenTarget) { return fmt.Errorf("unknown target") } @@ -44,7 +44,7 @@ func runBridgeTokenAdd(cmd *cobra.Command, args []string) error { value = strings.TrimSuffix(raw, "\n") } - token := core.NewToken(value, bridgeTokenTarget) + token := core.NewToken(value, bridgeAuthAddTokenTarget) if err := token.Validate(); err != nil { return errors.Wrap(err, "invalid token") } @@ -58,8 +58,8 @@ func runBridgeTokenAdd(cmd *cobra.Command, args []string) error { return nil } -var bridgeTokenAddCmd = &cobra.Command{ - Use: "add", +var bridgeAuthAddTokenCmd = &cobra.Command{ + Use: "add-token []", Short: "Store a new token", PreRunE: loadRepo, RunE: runBridgeTokenAdd, @@ -67,8 +67,8 @@ var bridgeTokenAddCmd = &cobra.Command{ } func init() { - bridgeTokenCmd.AddCommand(bridgeTokenAddCmd) - bridgeTokenAddCmd.Flags().StringVarP(&bridgeTokenTarget, "target", "t", "", + bridgeAuthCmd.AddCommand(bridgeAuthAddTokenCmd) + bridgeAuthAddTokenCmd.Flags().StringVarP(&bridgeAuthAddTokenTarget, "target", "t", "", fmt.Sprintf("The target of the bridge. Valid values are [%s]", strings.Join(bridge.Targets(), ","))) - bridgeTokenAddCmd.Flags().SortFlags = false + bridgeAuthAddTokenCmd.Flags().SortFlags = false } diff --git a/commands/bridge_token_rm.go b/commands/bridge_auth_rm.go similarity index 67% rename from commands/bridge_token_rm.go rename to commands/bridge_auth_rm.go index a73fbb914e7dc678156efc5a5294fe8005175b75..b0b4d437650724364d58d923cb9067ef8894d3b5 100644 --- a/commands/bridge_token_rm.go +++ b/commands/bridge_auth_rm.go @@ -8,7 +8,7 @@ import ( "github.com/MichaelMure/git-bug/bridge/core" ) -func runBridgeTokenRm(cmd *cobra.Command, args []string) error { +func runBridgeAuthRm(cmd *cobra.Command, args []string) error { token, err := core.LoadTokenPrefix(repo, args[0]) if err != nil { return err @@ -23,14 +23,14 @@ func runBridgeTokenRm(cmd *cobra.Command, args []string) error { return nil } -var bridgeTokenRmCmd = &cobra.Command{ +var bridgeAuthRmCmd = &cobra.Command{ Use: "rm ", - Short: "Remove a token.", + Short: "Remove a credential.", PreRunE: loadRepo, - RunE: runBridgeTokenRm, + RunE: runBridgeAuthRm, Args: cobra.ExactArgs(1), } func init() { - bridgeTokenCmd.AddCommand(bridgeTokenRmCmd) + bridgeAuthCmd.AddCommand(bridgeAuthRmCmd) } diff --git a/commands/bridge_token_show.go b/commands/bridge_auth_show.go similarity index 65% rename from commands/bridge_token_show.go rename to commands/bridge_auth_show.go index 2d2e824de538e531be7f19760b65ab218a95ef1c..94141b93d19a4dc41fb46ad15a0f17e944672b44 100644 --- a/commands/bridge_token_show.go +++ b/commands/bridge_auth_show.go @@ -9,28 +9,29 @@ import ( "github.com/MichaelMure/git-bug/bridge/core" ) -func runBridgeTokenShow(cmd *cobra.Command, args []string) error { +func runBridgeAuthShow(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("Type: token\n") + fmt.Printf("Value: %s\n", token.Value) fmt.Printf("Creation: %s\n", token.CreateTime.Format(time.RFC822)) return nil } -var bridgeTokenShowCmd = &cobra.Command{ +var bridgeAuthShowCmd = &cobra.Command{ Use: "show", - Short: "Display a token.", + Short: "Display an authentication credential.", PreRunE: loadRepo, - RunE: runBridgeTokenShow, + RunE: runBridgeAuthShow, Args: cobra.ExactArgs(1), } func init() { - bridgeTokenCmd.AddCommand(bridgeTokenShowCmd) + bridgeAuthCmd.AddCommand(bridgeAuthShowCmd) } diff --git a/doc/man/git-bug-bridge-token-add.1 b/doc/man/git-bug-bridge-auth-add-token.1 similarity index 67% rename from doc/man/git-bug-bridge-token-add.1 rename to doc/man/git-bug-bridge-auth-add-token.1 index 9b8a0db88078764e20f4c25ce722babf46096236..a76ed793ccad1a67b03ef6ebbac5212b2b6b789e 100644 --- a/doc/man/git-bug-bridge-token-add.1 +++ b/doc/man/git-bug-bridge-auth-add-token.1 @@ -5,12 +5,12 @@ .SH NAME .PP -git\-bug\-bridge\-token\-add \- Store a new token +git\-bug\-bridge\-auth\-add\-token \- Store a new token .SH SYNOPSIS .PP -\fBgit\-bug bridge token add [flags]\fP +\fBgit\-bug bridge auth add\-token [] [flags]\fP .SH DESCRIPTION @@ -25,9 +25,9 @@ Store a new token .PP \fB\-h\fP, \fB\-\-help\fP[=false] - help for add + help for add\-token .SH SEE ALSO .PP -\fBgit\-bug\-bridge\-token(1)\fP +\fBgit\-bug\-bridge\-auth(1)\fP diff --git a/doc/man/git-bug-bridge-token-rm.1 b/doc/man/git-bug-bridge-auth-rm.1 similarity index 60% rename from doc/man/git-bug-bridge-token-rm.1 rename to doc/man/git-bug-bridge-auth-rm.1 index 217d938ddf81f197142586f730b8ee9bbd3aceb2..b0222b72ede3f33a6e4ffb2945e54b8ded9d7bc5 100644 --- a/doc/man/git-bug-bridge-token-rm.1 +++ b/doc/man/git-bug-bridge-auth-rm.1 @@ -5,17 +5,17 @@ .SH NAME .PP -git\-bug\-bridge\-token\-rm \- Remove a token. +git\-bug\-bridge\-auth\-rm \- Remove a credential. .SH SYNOPSIS .PP -\fBgit\-bug bridge token rm [flags]\fP +\fBgit\-bug bridge auth rm [flags]\fP .SH DESCRIPTION .PP -Remove a token. +Remove a credential. .SH OPTIONS @@ -26,4 +26,4 @@ Remove a token. .SH SEE ALSO .PP -\fBgit\-bug\-bridge\-token(1)\fP +\fBgit\-bug\-bridge\-auth(1)\fP diff --git a/doc/man/git-bug-bridge-token-show.1 b/doc/man/git-bug-bridge-auth-show.1 similarity index 55% rename from doc/man/git-bug-bridge-token-show.1 rename to doc/man/git-bug-bridge-auth-show.1 index f40b50244f70f982b2aeaa2fd2508b0edbd440fd..6e0d345c2d9b16ce4d090caebe1d87649180c3ed 100644 --- a/doc/man/git-bug-bridge-token-show.1 +++ b/doc/man/git-bug-bridge-auth-show.1 @@ -5,17 +5,17 @@ .SH NAME .PP -git\-bug\-bridge\-token\-show \- Display a token. +git\-bug\-bridge\-auth\-show \- Display an authentication credential. .SH SYNOPSIS .PP -\fBgit\-bug bridge token show [flags]\fP +\fBgit\-bug bridge auth show [flags]\fP .SH DESCRIPTION .PP -Display a token. +Display an authentication credential. .SH OPTIONS @@ -26,4 +26,4 @@ Display a token. .SH SEE ALSO .PP -\fBgit\-bug\-bridge\-token(1)\fP +\fBgit\-bug\-bridge\-auth(1)\fP diff --git a/doc/man/git-bug-bridge-auth.1 b/doc/man/git-bug-bridge-auth.1 new file mode 100644 index 0000000000000000000000000000000000000000..0e400c41b97358f5e8265d429954e0bf1f2159e3 --- /dev/null +++ b/doc/man/git-bug-bridge-auth.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\-auth \- List all known bridge authentication credentials. + + +.SH SYNOPSIS +.PP +\fBgit\-bug bridge auth [flags]\fP + + +.SH DESCRIPTION +.PP +List all known bridge authentication credentials. + + +.SH OPTIONS +.PP +\fB\-h\fP, \fB\-\-help\fP[=false] + help for auth + + +.SH SEE ALSO +.PP +\fBgit\-bug\-bridge(1)\fP, \fBgit\-bug\-bridge\-auth\-add\-token(1)\fP, \fBgit\-bug\-bridge\-auth\-rm(1)\fP, \fBgit\-bug\-bridge\-auth\-show(1)\fP diff --git a/doc/man/git-bug-bridge-token.1 b/doc/man/git-bug-bridge-token.1 deleted file mode 100644 index f229bf76cf7dd927fd6c0f3ef6f5ec2e744c4cfb..0000000000000000000000000000000000000000 --- a/doc/man/git-bug-bridge-token.1 +++ /dev/null @@ -1,29 +0,0 @@ -.TH "GIT-BUG" "1" "Apr 2019" "Generated from git-bug's source code" "" -.nh -.ad l - - -.SH NAME -.PP -git\-bug\-bridge\-token \- List all known tokens. - - -.SH SYNOPSIS -.PP -\fBgit\-bug bridge token [flags]\fP - - -.SH DESCRIPTION -.PP -List all known tokens. - - -.SH OPTIONS -.PP -\fB\-h\fP, \fB\-\-help\fP[=false] - help for token - - -.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\-token\-show(1)\fP diff --git a/doc/man/git-bug-bridge.1 b/doc/man/git-bug-bridge.1 index f7e3ff85b5915a0954b1da7e701391f6a3f65092..8e885f1064fde5d89fb9dec2fe46207f2f75fcaa 100644 --- a/doc/man/git-bug-bridge.1 +++ b/doc/man/git-bug-bridge.1 @@ -26,4 +26,4 @@ Configure and use bridges to other bug trackers. .SH SEE ALSO .PP -\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-pull(1)\fP, \fBgit\-bug\-bridge\-push(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP, \fBgit\-bug\-bridge\-token(1)\fP +\fBgit\-bug(1)\fP, \fBgit\-bug\-bridge\-auth(1)\fP, \fBgit\-bug\-bridge\-configure(1)\fP, \fBgit\-bug\-bridge\-pull(1)\fP, \fBgit\-bug\-bridge\-push(1)\fP, \fBgit\-bug\-bridge\-rm(1)\fP diff --git a/doc/md/git-bug_bridge.md b/doc/md/git-bug_bridge.md index 073d23ffae4ad9add5223c89300f8f5fd3e06069..3ddb98920a97661ba7a0a64872533f5b3c488e0e 100644 --- a/doc/md/git-bug_bridge.md +++ b/doc/md/git-bug_bridge.md @@ -19,9 +19,9 @@ git-bug bridge [flags] ### SEE ALSO * [git-bug](git-bug.md) - A bug tracker embedded in Git. +* [git-bug bridge auth](git-bug_bridge_auth.md) - List all known bridge authentication credentials. * [git-bug bridge configure](git-bug_bridge_configure.md) - Configure a new bridge. * [git-bug bridge pull](git-bug_bridge_pull.md) - Pull updates. * [git-bug bridge push](git-bug_bridge_push.md) - Push updates. * [git-bug bridge rm](git-bug_bridge_rm.md) - Delete a configured bridge. -* [git-bug bridge token](git-bug_bridge_token.md) - List all known tokens. diff --git a/doc/md/git-bug_bridge_auth.md b/doc/md/git-bug_bridge_auth.md new file mode 100644 index 0000000000000000000000000000000000000000..e953f0ecae6ce16dec9fb208b79fbfaf5a7a87e7 --- /dev/null +++ b/doc/md/git-bug_bridge_auth.md @@ -0,0 +1,25 @@ +## git-bug bridge auth + +List all known bridge authentication credentials. + +### Synopsis + +List all known bridge authentication credentials. + +``` +git-bug bridge auth [flags] +``` + +### Options + +``` + -h, --help help for auth +``` + +### SEE ALSO + +* [git-bug bridge](git-bug_bridge.md) - Configure and use bridges to other bug trackers. +* [git-bug bridge auth add-token](git-bug_bridge_auth_add-token.md) - Store a new token +* [git-bug bridge auth rm](git-bug_bridge_auth_rm.md) - Remove a credential. +* [git-bug bridge auth show](git-bug_bridge_auth_show.md) - Display an authentication credential. + diff --git a/doc/md/git-bug_bridge_auth_add-token.md b/doc/md/git-bug_bridge_auth_add-token.md new file mode 100644 index 0000000000000000000000000000000000000000..7067c3caa076802c61429f9027ee287b685de2bb --- /dev/null +++ b/doc/md/git-bug_bridge_auth_add-token.md @@ -0,0 +1,23 @@ +## git-bug bridge auth add-token + +Store a new token + +### Synopsis + +Store a new token + +``` +git-bug bridge auth add-token [] [flags] +``` + +### Options + +``` + -t, --target string The target of the bridge. Valid values are [github,gitlab,launchpad-preview] + -h, --help help for add-token +``` + +### SEE ALSO + +* [git-bug bridge auth](git-bug_bridge_auth.md) - List all known bridge authentication credentials. + diff --git a/doc/md/git-bug_bridge_auth_rm.md b/doc/md/git-bug_bridge_auth_rm.md new file mode 100644 index 0000000000000000000000000000000000000000..059aa43dcdd709e538f4116323499a8ea9451cac --- /dev/null +++ b/doc/md/git-bug_bridge_auth_rm.md @@ -0,0 +1,22 @@ +## git-bug bridge auth rm + +Remove a credential. + +### Synopsis + +Remove a credential. + +``` +git-bug bridge auth rm [flags] +``` + +### Options + +``` + -h, --help help for rm +``` + +### SEE ALSO + +* [git-bug bridge auth](git-bug_bridge_auth.md) - List all known bridge authentication credentials. + diff --git a/doc/md/git-bug_bridge_auth_show.md b/doc/md/git-bug_bridge_auth_show.md new file mode 100644 index 0000000000000000000000000000000000000000..5da3820f8bcfe1fb5aa6bffc8f91d8a2adf02307 --- /dev/null +++ b/doc/md/git-bug_bridge_auth_show.md @@ -0,0 +1,22 @@ +## git-bug bridge auth show + +Display an authentication credential. + +### Synopsis + +Display an authentication credential. + +``` +git-bug bridge auth show [flags] +``` + +### Options + +``` + -h, --help help for show +``` + +### SEE ALSO + +* [git-bug bridge auth](git-bug_bridge_auth.md) - List all known bridge authentication credentials. + diff --git a/doc/md/git-bug_bridge_token.md b/doc/md/git-bug_bridge_token.md deleted file mode 100644 index 14663784bbd32fdfbf5cb7ac3d427218a677ede0..0000000000000000000000000000000000000000 --- a/doc/md/git-bug_bridge_token.md +++ /dev/null @@ -1,25 +0,0 @@ -## git-bug bridge token - -List all known tokens. - -### Synopsis - -List all known tokens. - -``` -git-bug bridge token [flags] -``` - -### Options - -``` - -h, --help help for token -``` - -### SEE ALSO - -* [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 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_add.md b/doc/md/git-bug_bridge_token_add.md deleted file mode 100644 index 1c0e5bbc5017d68f87d0b1f1f21a095d3f6ab50b..0000000000000000000000000000000000000000 --- a/doc/md/git-bug_bridge_token_add.md +++ /dev/null @@ -1,23 +0,0 @@ -## git-bug bridge token add - -Store a new token - -### Synopsis - -Store a new token - -``` -git-bug bridge token add [flags] -``` - -### Options - -``` - -t, --target string The target of the bridge. Valid values are [github,gitlab,launchpad-preview] - -h, --help help for add -``` - -### SEE ALSO - -* [git-bug bridge token](git-bug_bridge_token.md) - List all known tokens. - diff --git a/doc/md/git-bug_bridge_token_rm.md b/doc/md/git-bug_bridge_token_rm.md deleted file mode 100644 index 534406f4afb888d3a7c866e4d8048c35076e5606..0000000000000000000000000000000000000000 --- a/doc/md/git-bug_bridge_token_rm.md +++ /dev/null @@ -1,22 +0,0 @@ -## git-bug bridge token rm - -Remove a token. - -### Synopsis - -Remove a token. - -``` -git-bug bridge token rm [flags] -``` - -### Options - -``` - -h, --help help for rm -``` - -### SEE ALSO - -* [git-bug bridge token](git-bug_bridge_token.md) - List all known tokens. - diff --git a/doc/md/git-bug_bridge_token_show.md b/doc/md/git-bug_bridge_token_show.md deleted file mode 100644 index 80439617a6bf9b6c282cef29721cb7557aa1c12a..0000000000000000000000000000000000000000 --- a/doc/md/git-bug_bridge_token_show.md +++ /dev/null @@ -1,22 +0,0 @@ -## 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 e8126b8f5f664418df4f6de17d466b455f7a43de..9dc3ac87a107fce96235763ef27d0fd9d6e4a209 100644 --- a/misc/bash_completion/git-bug +++ b/misc/bash_completion/git-bug @@ -287,9 +287,9 @@ _git-bug_add() noun_aliases=() } -_git-bug_bridge_configure() +_git-bug_bridge_auth_add-token() { - last_command="git-bug_bridge_configure" + last_command="git-bug_bridge_auth_add-token" command_aliases=() @@ -301,41 +301,19 @@ _git-bug_bridge_configure() flags_with_completion=() flags_completion=() - flags+=("--name=") - two_word_flags+=("--name") - two_word_flags+=("-n") - local_nonpersistent_flags+=("--name=") flags+=("--target=") two_word_flags+=("--target") two_word_flags+=("-t") local_nonpersistent_flags+=("--target=") - flags+=("--url=") - two_word_flags+=("--url") - two_word_flags+=("-u") - local_nonpersistent_flags+=("--url=") - flags+=("--owner=") - two_word_flags+=("--owner") - two_word_flags+=("-o") - local_nonpersistent_flags+=("--owner=") - flags+=("--token=") - two_word_flags+=("--token") - two_word_flags+=("-T") - local_nonpersistent_flags+=("--token=") - flags+=("--token-stdin") - local_nonpersistent_flags+=("--token-stdin") - flags+=("--project=") - two_word_flags+=("--project") - two_word_flags+=("-p") - local_nonpersistent_flags+=("--project=") must_have_one_flag=() must_have_one_noun=() noun_aliases=() } -_git-bug_bridge_pull() +_git-bug_bridge_auth_rm() { - last_command="git-bug_bridge_pull" + last_command="git-bug_bridge_auth_rm" command_aliases=() @@ -347,22 +325,15 @@ _git-bug_bridge_pull() flags_with_completion=() flags_completion=() - flags+=("--no-resume") - flags+=("-n") - local_nonpersistent_flags+=("--no-resume") - flags+=("--since=") - two_word_flags+=("--since") - two_word_flags+=("-s") - local_nonpersistent_flags+=("--since=") must_have_one_flag=() must_have_one_noun=() noun_aliases=() } -_git-bug_bridge_push() +_git-bug_bridge_auth_show() { - last_command="git-bug_bridge_push" + last_command="git-bug_bridge_auth_show" command_aliases=() @@ -380,13 +351,16 @@ _git-bug_bridge_push() noun_aliases=() } -_git-bug_bridge_rm() +_git-bug_bridge_auth() { - last_command="git-bug_bridge_rm" + last_command="git-bug_bridge_auth" command_aliases=() commands=() + commands+=("add-token") + commands+=("rm") + commands+=("show") flags=() two_word_flags=() @@ -400,9 +374,9 @@ _git-bug_bridge_rm() noun_aliases=() } -_git-bug_bridge_token_add() +_git-bug_bridge_configure() { - last_command="git-bug_bridge_token_add" + last_command="git-bug_bridge_configure" command_aliases=() @@ -414,19 +388,41 @@ _git-bug_bridge_token_add() flags_with_completion=() flags_completion=() + flags+=("--name=") + two_word_flags+=("--name") + two_word_flags+=("-n") + local_nonpersistent_flags+=("--name=") flags+=("--target=") two_word_flags+=("--target") two_word_flags+=("-t") local_nonpersistent_flags+=("--target=") + flags+=("--url=") + two_word_flags+=("--url") + two_word_flags+=("-u") + local_nonpersistent_flags+=("--url=") + flags+=("--owner=") + two_word_flags+=("--owner") + two_word_flags+=("-o") + local_nonpersistent_flags+=("--owner=") + flags+=("--token=") + two_word_flags+=("--token") + two_word_flags+=("-T") + local_nonpersistent_flags+=("--token=") + flags+=("--token-stdin") + local_nonpersistent_flags+=("--token-stdin") + flags+=("--project=") + two_word_flags+=("--project") + two_word_flags+=("-p") + local_nonpersistent_flags+=("--project=") must_have_one_flag=() must_have_one_noun=() noun_aliases=() } -_git-bug_bridge_token_rm() +_git-bug_bridge_pull() { - last_command="git-bug_bridge_token_rm" + last_command="git-bug_bridge_pull" command_aliases=() @@ -438,15 +434,22 @@ _git-bug_bridge_token_rm() flags_with_completion=() flags_completion=() + flags+=("--no-resume") + flags+=("-n") + local_nonpersistent_flags+=("--no-resume") + flags+=("--since=") + two_word_flags+=("--since") + two_word_flags+=("-s") + local_nonpersistent_flags+=("--since=") must_have_one_flag=() must_have_one_noun=() noun_aliases=() } -_git-bug_bridge_token_show() +_git-bug_bridge_push() { - last_command="git-bug_bridge_token_show" + last_command="git-bug_bridge_push" command_aliases=() @@ -464,16 +467,13 @@ _git-bug_bridge_token_show() noun_aliases=() } -_git-bug_bridge_token() +_git-bug_bridge_rm() { - last_command="git-bug_bridge_token" + last_command="git-bug_bridge_rm" command_aliases=() commands=() - commands+=("add") - commands+=("rm") - commands+=("show") flags=() two_word_flags=() @@ -494,11 +494,11 @@ _git-bug_bridge() command_aliases=() commands=() + commands+=("auth") commands+=("configure") commands+=("pull") commands+=("push") commands+=("rm") - commands+=("token") flags=() two_word_flags=() diff --git a/misc/powershell_completion/git-bug b/misc/powershell_completion/git-bug index 6a7bf0c33396ccb08d00012e62164bbf17af8365..5f0439329b024624ca0f3ed4889974bc9d737af2 100644 --- a/misc/powershell_completion/git-bug +++ b/misc/powershell_completion/git-bug @@ -48,11 +48,28 @@ Register-ArgumentCompleter -Native -CommandName 'git-bug' -ScriptBlock { break } 'git-bug;bridge' { + [CompletionResult]::new('auth', 'auth', [CompletionResultType]::ParameterValue, 'List all known bridge authentication credentials.') [CompletionResult]::new('configure', 'configure', [CompletionResultType]::ParameterValue, 'Configure a new bridge.') [CompletionResult]::new('pull', 'pull', [CompletionResultType]::ParameterValue, 'Pull updates.') [CompletionResult]::new('push', 'push', [CompletionResultType]::ParameterValue, 'Push updates.') [CompletionResult]::new('rm', 'rm', [CompletionResultType]::ParameterValue, 'Delete a configured bridge.') - [CompletionResult]::new('token', 'token', [CompletionResultType]::ParameterValue, 'List all known tokens.') + break + } + 'git-bug;bridge;auth' { + [CompletionResult]::new('add-token', 'add-token', [CompletionResultType]::ParameterValue, 'Store a new token') + [CompletionResult]::new('rm', 'rm', [CompletionResultType]::ParameterValue, 'Remove a credential.') + [CompletionResult]::new('show', 'show', [CompletionResultType]::ParameterValue, 'Display an authentication credential.') + break + } + 'git-bug;bridge;auth;add-token' { + [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'The target of the bridge. Valid values are [github,gitlab,launchpad-preview]') + [CompletionResult]::new('--target', 'target', [CompletionResultType]::ParameterName, 'The target of the bridge. Valid values are [github,gitlab,launchpad-preview]') + break + } + 'git-bug;bridge;auth;rm' { + break + } + 'git-bug;bridge;auth;show' { break } 'git-bug;bridge;configure' { @@ -84,23 +101,6 @@ Register-ArgumentCompleter -Native -CommandName 'git-bug' -ScriptBlock { 'git-bug;bridge;rm' { break } - 'git-bug;bridge;token' { - [CompletionResult]::new('add', 'add', [CompletionResultType]::ParameterValue, 'Store a new token') - [CompletionResult]::new('rm', 'rm', [CompletionResultType]::ParameterValue, 'Remove a token.') - [CompletionResult]::new('show', 'show', [CompletionResultType]::ParameterValue, 'Display a token.') - break - } - 'git-bug;bridge;token;add' { - [CompletionResult]::new('-t', 't', [CompletionResultType]::ParameterName, 'The target of the bridge. Valid values are [github,gitlab,launchpad-preview]') - [CompletionResult]::new('--target', 'target', [CompletionResultType]::ParameterName, 'The target of the bridge. Valid values are [github,gitlab,launchpad-preview]') - break - } - '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 f0ff7edfe9ec36b8a458ddfa0a9afc4351bfa664..230061dd6e859a2e7328143adf6254db95ca1e0f 100644 --- a/misc/zsh_completion/git-bug +++ b/misc/zsh_completion/git-bug @@ -114,17 +114,20 @@ function _git-bug_bridge { case $state in cmnds) commands=( + "auth:List all known bridge authentication credentials." "configure:Configure a new bridge." "pull:Pull updates." "push:Push updates." "rm:Delete a configured bridge." - "token:List all known tokens." ) _describe "command" commands ;; esac case "$words[1]" in + auth) + _git-bug_bridge_auth + ;; configure) _git-bug_bridge_configure ;; @@ -137,39 +140,11 @@ function _git-bug_bridge { rm) _git-bug_bridge_rm ;; - token) - _git-bug_bridge_token - ;; esac } -function _git-bug_bridge_configure { - _arguments \ - '(-n --name)'{-n,--name}'[A distinctive name to identify the bridge]:' \ - '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,launchpad-preview]]:' \ - '(-u --url)'{-u,--url}'[The URL of the target repository]:' \ - '(-o --owner)'{-o,--owner}'[The owner of the target repository]:' \ - '(-T --token)'{-T,--token}'[The authentication token for the API]:' \ - '--token-stdin[Will read the token from stdin and ignore --token]' \ - '(-p --project)'{-p,--project}'[The name of the target repository]:' -} - -function _git-bug_bridge_pull { - _arguments \ - '(-n --no-resume)'{-n,--no-resume}'[force importing all bugs]' \ - '(-s --since)'{-s,--since}'[import only bugs updated after the given date (ex: "200h" or "june 2 2019")]:' -} - -function _git-bug_bridge_push { - _arguments -} - -function _git-bug_bridge_rm { - _arguments -} - -function _git-bug_bridge_token { +function _git-bug_bridge_auth { local -a commands _arguments -C \ @@ -179,37 +154,62 @@ function _git-bug_bridge_token { case $state in cmnds) commands=( - "add:Store a new token" - "rm:Remove a token." - "show:Display a token." + "add-token:Store a new token" + "rm:Remove a credential." + "show:Display an authentication credential." ) _describe "command" commands ;; esac case "$words[1]" in - add) - _git-bug_bridge_token_add + add-token) + _git-bug_bridge_auth_add-token ;; rm) - _git-bug_bridge_token_rm + _git-bug_bridge_auth_rm ;; show) - _git-bug_bridge_token_show + _git-bug_bridge_auth_show ;; esac } -function _git-bug_bridge_token_add { +function _git-bug_bridge_auth_add-token { _arguments \ '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,launchpad-preview]]:' } -function _git-bug_bridge_token_rm { +function _git-bug_bridge_auth_rm { + _arguments +} + +function _git-bug_bridge_auth_show { + _arguments +} + +function _git-bug_bridge_configure { + _arguments \ + '(-n --name)'{-n,--name}'[A distinctive name to identify the bridge]:' \ + '(-t --target)'{-t,--target}'[The target of the bridge. Valid values are [github,gitlab,launchpad-preview]]:' \ + '(-u --url)'{-u,--url}'[The URL of the target repository]:' \ + '(-o --owner)'{-o,--owner}'[The owner of the target repository]:' \ + '(-T --token)'{-T,--token}'[The authentication token for the API]:' \ + '--token-stdin[Will read the token from stdin and ignore --token]' \ + '(-p --project)'{-p,--project}'[The name of the target repository]:' +} + +function _git-bug_bridge_pull { + _arguments \ + '(-n --no-resume)'{-n,--no-resume}'[force importing all bugs]' \ + '(-s --since)'{-s,--since}'[import only bugs updated after the given date (ex: "200h" or "june 2 2019")]:' +} + +function _git-bug_bridge_push { _arguments } -function _git-bug_bridge_token_show { +function _git-bug_bridge_rm { _arguments }