forked from direnv/direnv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshell_json.go
More file actions
35 lines (29 loc) · 729 Bytes
/
Copy pathshell_json.go
File metadata and controls
35 lines (29 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"encoding/json"
"errors"
)
// jsonShell is not a real shell
type jsonShell struct{}
// JSON is not really a shell but it fits. Useful to add support to editor and
// other external tools that understand JSON as a format.
var JSON Shell = jsonShell{}
func (sh jsonShell) Hook() (string, error) {
return "", errors.New("this feature is not supported")
}
func (sh jsonShell) Export(e ShellExport) string {
out, err := json.MarshalIndent(e, "", " ")
if err != nil {
// Should never happen
panic(err)
}
return string(out)
}
func (sh jsonShell) Dump(env Env) string {
out, err := json.MarshalIndent(env, "", " ")
if err != nil {
// Should never happen
panic(err)
}
return string(out)
}