1package main 2 3import ( 4 "encoding/json" 5 "fmt" 6 "os" 7 8 "github.com/direnv/direnv/gzenv" 9) 10 11// CmdShowDump is `direnv show_dump` 12var CmdShowDump = &Cmd{ 13 Name: "show_dump", 14 Desc: "Show the data inside of a dump for debugging purposes", 15 Args: []string{"DUMP"}, 16 Private: true, 17 Action: actionSimple(cmdShowDumpAction), 18} 19 20func cmdShowDumpAction(env Env, args []string) (err error) { 21 if len(args) < 2 { 22 return fmt.Errorf("missing DUMP argument") 23 } 24 25 var f interface{} 26 err = gzenv.Unmarshal(args[1], &f) 27 if err != nil { 28 return err 29 } 30 31 e := json.NewEncoder(os.Stdout) 32 e.SetIndent("", " ") 33 return e.Encode(f) 34} 35