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

Function Export

cmd/export.go:13–39  ·  view source on GitHub ↗

Export returns `export` command

(cfg storage)

Source from the content-addressed store, hash-verified

11
12// Export returns `export` command
13func Export(cfg storage) *cobra.Command {
14 return &cobra.Command{
15 Use: "export [profile]",
16 Aliases: []string{"e"},
17 Short: "Export a profile",
18 Long: "Export a profile as JSON.",
19 Args: cobra.ExactArgs(1),
20 Example: "git-profile export my-profile",
21 Run: func(cmd *cobra.Command, args []string) {
22 profile := args[0]
23
24 entries, ok := cfg.Lookup(profile)
25 if !ok {
26 ui.PrintErrln(cmd, ui.ErrorStyle, "There is no profile with `%s` name", profile)
27 os.Exit(0)
28 }
29
30 data, err := json.Marshal(entries)
31 if err != nil {
32 ui.PrintErrln(cmd, ui.ErrorStyle, "Unable to encode profile values: %s", err)
33 os.Exit(1)
34 }
35
36 cmd.Println(string(data))
37 },
38 }
39}

Callers 2

TestExportFunction · 0.85
initMethod · 0.85

Calls 2

PrintErrlnFunction · 0.92
LookupMethod · 0.65

Tested by 1

TestExportFunction · 0.68