( cfg storage, v vcs, selectProfile func([]string, io.Reader, io.Writer) (string, error), )
| 16 | } |
| 17 | |
| 18 | func useCommand( |
| 19 | cfg storage, |
| 20 | v vcs, |
| 21 | selectProfile func([]string, io.Reader, io.Writer) (string, error), |
| 22 | ) *cobra.Command { |
| 23 | return &cobra.Command{ |
| 24 | Use: "use [profile]", |
| 25 | Aliases: []string{"u"}, |
| 26 | Short: "Use a profile", |
| 27 | Long: "Applies the selected profile entries to the current git repository.", |
| 28 | Example: multiline( |
| 29 | `git-profile use`, |
| 30 | `git-profile use my-profile`, |
| 31 | ), |
| 32 | PreRun: func(cmd *cobra.Command, _ []string) { |
| 33 | check(cmd, cfg, v) |
| 34 | }, |
| 35 | Run: func(cmd *cobra.Command, args []string) { |
| 36 | profile, err := profileResolve(args, cmd.InOrStdin(), cmd.OutOrStdout(), cfg, selectProfile) |
| 37 | if err != nil { |
| 38 | ui.PrintErrln(cmd, ui.ErrorStyle, "%s", err) |
| 39 | os.Exit(1) |
| 40 | } |
| 41 | |
| 42 | profileApply(cmd, cfg, v, profile) |
| 43 | }, |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | func profileResolve( |
| 48 | args []string, |
no test coverage detected