MCPcopy Create free account
hub / github.com/dotzero/git-profile / useCommand

Function useCommand

cmd/use.go:18–45  ·  view source on GitHub ↗
(
	cfg storage,
	v vcs,
	selectProfile func([]string, io.Reader, io.Writer) (string, error),
)

Source from the content-addressed store, hash-verified

16}
17
18func 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
47func profileResolve(
48 args []string,

Callers 1

UseFunction · 0.85

Calls 5

PrintErrlnFunction · 0.92
multilineFunction · 0.85
checkFunction · 0.85
profileResolveFunction · 0.85
profileApplyFunction · 0.85

Tested by

no test coverage detected