(f *cmdutil.Factory, runF func(*CredentialOptions) error)
| 26 | } |
| 27 | |
| 28 | func NewCmdCredential(f *cmdutil.Factory, runF func(*CredentialOptions) error) *cobra.Command { |
| 29 | opts := &CredentialOptions{ |
| 30 | IO: f.IOStreams, |
| 31 | Config: func() (config, error) { |
| 32 | cfg, err := f.Config() |
| 33 | if err != nil { |
| 34 | return nil, err |
| 35 | } |
| 36 | return cfg.Authentication(), nil |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | cmd := &cobra.Command{ |
| 41 | Use: "git-credential", |
| 42 | Args: cobra.ExactArgs(1), |
| 43 | Short: "Implements git credential helper protocol", |
| 44 | Hidden: true, |
| 45 | RunE: func(cmd *cobra.Command, args []string) error { |
| 46 | opts.Operation = args[0] |
| 47 | |
| 48 | if runF != nil { |
| 49 | return runF(opts) |
| 50 | } |
| 51 | return helperRun(opts) |
| 52 | }, |
| 53 | } |
| 54 | |
| 55 | return cmd |
| 56 | } |
| 57 | |
| 58 | func helperRun(opts *CredentialOptions) error { |
| 59 | if opts.Operation == "store" { |
nothing calls this directly
no test coverage detected