oh-my-posh/src/segment_php.go

31 lines
806 B
Go
Raw Normal View History

2021-10-27 01:52:56 -07:00
package main
type php struct {
2021-12-03 11:19:57 -08:00
language
2021-10-27 01:52:56 -07:00
}
2022-01-22 10:46:56 -08:00
func (p *php) string() string {
segmentTemplate := p.language.props.getString(SegmentTemplate, "{{ if .Error }}{{ .Error }}{{ else }}{{ .Full }}{{ end }}")
return p.language.string(segmentTemplate, p)
2021-10-27 01:52:56 -07:00
}
2022-01-22 10:46:56 -08:00
func (p *php) init(props Properties, env Environment) {
p.language = language{
2021-10-27 01:52:56 -07:00
env: env,
props: props,
extensions: []string{"*.php", "composer.json", "composer.lock", ".php-version"},
2021-10-27 01:52:56 -07:00
commands: []*cmd{
{
executable: "php",
args: []string{"--version"},
regex: `(?:PHP (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+))))`,
},
},
versionURLTemplate: "[%[1]s](https://www.php.net/ChangeLog-%[2]s.php#PHP_%[2]s_%[3]s)",
}
}
2022-01-22 10:46:56 -08:00
func (p *php) enabled() bool {
return p.language.enabled()
2021-10-27 01:52:56 -07:00
}