-
Notifications
You must be signed in to change notification settings - Fork 0
/
manifest.go
53 lines (44 loc) · 1.09 KB
/
manifest.go
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package dsjas
import "encoding/json"
const (
// File name for the DSJAS plugin manifest.
ManifestFile = ".dsjasManifest"
)
// Plugin type definitions. Used for format extension manifest file types.
const (
PluginTheme = iota
PluginModule
// Currently unused.
PluginExtension
)
// PluginType holds the integer representation of a plugin type.
type PluginType uint8
// Returns the correctly stringified PluginType.
func (t PluginType) MarshalJSON() ([]byte, error) {
return []byte("\"" + t.String() + "\""), nil
}
func (t PluginType) String() string {
switch t {
case PluginTheme:
return "theme"
case PluginModule:
return "module"
case PluginExtension:
return "extension"
default:
return "unknown"
}
}
// PluginManifest is a JSON representation of the .dsjasManifest file.
type PluginManifest struct {
Name string `json:"name"`
Type PluginType `json:"extension-type"`
}
// Returns the stringified JSON representation of the manifest file.
func (p PluginManifest) String() string {
out, err := json.MarshalIndent(p, "", "\t")
if err != nil {
panic(err)
}
return string(out)
}