oh-my-posh/src/segments/dotnet.go

44 lines
1.3 KiB
Go
Raw Normal View History

2022-01-26 06:54:36 -08:00
package segments
import (
2022-01-26 06:54:36 -08:00
"oh-my-posh/constants"
"oh-my-posh/environment"
"oh-my-posh/properties"
)
2022-01-26 05:10:18 -08:00
type Dotnet struct {
2021-12-03 11:19:57 -08:00
language
2022-01-22 10:46:56 -08:00
Unsupported bool
}
func (d *Dotnet) Template() string {
return "{{ if .Unsupported }}\uf071{{ else }}{{ .Full }}{{ end }}"
}
func (d *Dotnet) Init(props properties.Properties, env environment.Environment) {
2021-12-03 11:19:57 -08:00
d.language = language{
2021-02-03 10:11:32 -08:00
env: env,
props: props,
extensions: []string{"*.cs", "*.csx", "*.vb", "*.sln", "*.csproj", "*.vbproj", "*.fs", "*.fsx", "*.fsproj", "global.json"},
2021-02-03 10:11:32 -08:00
commands: []*cmd{
{
executable: "dotnet",
args: []string{"--version"},
2021-11-07 10:55:22 -08:00
regex: `(?P<version>((?P<major>0|[1-9]\d*)\.(?P<minor>0|[1-9]\d*)\.(?P<patch>0|[1-9]\d*)` +
`(?:-(?P<prerelease>(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+(?P<buildmetadata>[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?))`,
2021-02-03 10:11:32 -08:00
},
},
2022-01-23 09:48:55 -08:00
versionURLTemplate: "https://github.com/dotnet/core/blob/master/release-notes/{{ .Major }}.{{ .Minor }}/{{ .Major }}.{{ .Minor }}.{{ .Patch }}/{{ .Major }}.{{ .Minor }}.{{ .Patch }}.md)", // nolint: lll
}
}
func (d *Dotnet) Enabled() bool {
enabled := d.language.Enabled()
2022-01-22 10:46:56 -08:00
if !enabled {
return false
}
2022-01-26 06:54:36 -08:00
d.Unsupported = d.language.exitCode == constants.DotnetExitCode
2022-01-22 10:46:56 -08:00
return true
}