diff options
author | Michael Muré <batolettre@gmail.com> | 2022-09-10 11:09:19 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-11-20 17:18:09 +0100 |
commit | acc9a6f3a6df2961c3ae44352216d915cb9b5315 (patch) | |
tree | e159372673104ade1f15ddc1a84aa9da93e93552 /commands/bridge_auth.go | |
parent | a3fa445a9c76631c4cd16f93e1c1c68a954adef7 (diff) | |
download | git-bug-acc9a6f3a6df2961c3ae44352216d915cb9b5315.tar.gz |
commands: reorg into different packages
Diffstat (limited to 'commands/bridge_auth.go')
-rw-r--r-- | commands/bridge_auth.go | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/commands/bridge_auth.go b/commands/bridge_auth.go deleted file mode 100644 index 50306b8d..00000000 --- a/commands/bridge_auth.go +++ /dev/null @@ -1,67 +0,0 @@ -package commands - -import ( - "sort" - "strings" - - "github.com/spf13/cobra" - - text "github.com/MichaelMure/go-term-text" - - "github.com/MichaelMure/git-bug/bridge/core/auth" - "github.com/MichaelMure/git-bug/util/colors" -) - -func newBridgeAuthCommand() *cobra.Command { - env := newEnv() - - cmd := &cobra.Command{ - Use: "auth", - Short: "List all known bridge authentication credentials.", - PreRunE: loadBackend(env), - RunE: closeBackend(env, func(cmd *cobra.Command, args []string) error { - return runBridgeAuth(env) - }), - Args: cobra.NoArgs, - } - - cmd.AddCommand(newBridgeAuthAddTokenCommand()) - cmd.AddCommand(newBridgeAuthRm()) - cmd.AddCommand(newBridgeAuthShow()) - - return cmd -} - -func runBridgeAuth(env *Env) error { - creds, err := auth.List(env.backend) - if err != nil { - return err - } - - for _, cred := range creds { - targetFmt := text.LeftPadMaxLine(cred.Target(), 10, 0) - - var value string - switch cred := cred.(type) { - case *auth.Token: - value = cred.Value - } - - meta := make([]string, 0, len(cred.Metadata())) - for k, v := range cred.Metadata() { - meta = append(meta, k+":"+v) - } - sort.Strings(meta) - metaFmt := strings.Join(meta, ",") - - env.out.Printf("%s %s %s %s %s\n", - colors.Cyan(cred.ID().Human()), - colors.Yellow(targetFmt), - colors.Magenta(cred.Kind()), - value, - metaFmt, - ) - } - - return nil -} |