oh-my-posh/src/segment_crystal.go

31 lines
788 B
Go
Raw Normal View History

2021-05-14 04:39:49 -07:00
package main
type crystal struct {
2021-12-03 11:19:57 -08:00
language
2021-05-14 04:39:49 -07:00
}
func (c *crystal) string() string {
segmentTemplate := c.language.props.getString(SegmentTemplate, "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}")
return c.language.string(segmentTemplate, c)
2021-05-14 04:39:49 -07:00
}
2022-01-01 11:09:52 -08:00
func (c *crystal) init(props Properties, env Environment) {
2021-12-03 11:19:57 -08:00
c.language = language{
2021-05-14 04:39:49 -07:00
env: env,
props: props,
extensions: []string{"*.cr", "shard.yml"},
commands: []*cmd{
{
executable: "crystal",
args: []string{"--version"},
regex: `Crystal (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
},
},
2022-01-23 09:48:55 -08:00
versionURLTemplate: "https://github.com/crystal-lang/crystal/releases/tag/{{ .Full }}",
2021-05-14 04:39:49 -07:00
}
}
func (c *crystal) enabled() bool {
return c.language.enabled()
}