MCPcopy
hub / github.com/perkeep/perkeep / RunCommand

Method RunCommand

cmd/pk/dumpconfig.go:47–69  ·  view source on GitHub ↗
(args []string)

Source from the content-addressed store, hash-verified

45}
46
47func (c *dumpconfigCmd) RunCommand(args []string) error {
48 var file string
49 switch {
50 case len(args) == 0:
51 file = osutil.UserServerConfigPath()
52 case len(args) == 1:
53 file = args[0]
54 default:
55 return errors.New("More than 1 argument not allowed")
56 }
57 cfg, err := serverinit.LoadFile(file)
58 if err != nil {
59 return err
60 }
61 lowj, err := json.MarshalIndent(cfg.LowLevelJSONConfig(), "", " ") //lint:ignore SA1019 we use it still
62 if err != nil {
63 return err
64 }
65 knownKeys := regexp.MustCompile(`(?ms)^\s+"_knownkeys": {.+?},?\n`)
66 lowj = knownKeys.ReplaceAll(lowj, nil)
67 _, err = os.Stdout.Write(lowj)
68 return err
69}

Callers

nothing calls this directly

Calls 4

UserServerConfigPathFunction · 0.92
LoadFileFunction · 0.92
LowLevelJSONConfigMethod · 0.80
WriteMethod · 0.45

Tested by

no test coverage detected