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

Method init

cmd/root.go:64–98  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

62}
63
64func (c *Cmd) init() {
65 cobra.OnInitialize(func() {
66 filename, err := homedir.Expand(c.filename)
67 if err != nil {
68 c.PrintErrln(err)
69 os.Exit(1)
70 }
71
72 err = c.config.Load(filename)
73 if err != nil {
74 c.PrintErrln("Unable to load config:", err)
75 os.Exit(1)
76 }
77
78 c.filename = filename
79 })
80
81 c.AddCommand(
82 Add(c.config),
83 Completion(&c.Command),
84 Current(c.config, c.git),
85 Del(c.config),
86 List(c.config, c.git),
87 Export(c.config),
88 Import(c.config),
89 Use(c.config, c.git),
90 Unuse(c.config, c.git),
91 Version(c),
92 )
93
94 c.SetOutput(os.Stdout)
95 c.SetErr(os.Stderr)
96
97 c.PersistentFlags().StringVarP(&c.filename, "config", "c", "~/.gitprofile", "config file")
98}
99
100func multiline(lines ...string) string {
101 return strings.Join(lines, "\n")

Callers 1

ExecuteMethod · 0.95

Calls 11

AddFunction · 0.85
CompletionFunction · 0.85
CurrentFunction · 0.85
DelFunction · 0.85
ListFunction · 0.85
ExportFunction · 0.85
ImportFunction · 0.85
UseFunction · 0.85
UnuseFunction · 0.85
VersionFunction · 0.85
LoadMethod · 0.65

Tested by

no test coverage detected