oh-my-posh/src/segment_dotnet.go

44 lines
1.3 KiB
Go
Raw Normal View History

package main
type dotnet struct {
2021-12-03 11:19:57 -08:00
language
}
const (
// UnsupportedDotnetVersionIcon is displayed when the dotnet version in
// the current folder isn't supported by the installed dotnet SDK set.
UnsupportedDotnetVersionIcon Property = "unsupported_version_icon"
)
func (d *dotnet) string() string {
version := d.language.string()
exitCode := d.language.exitCode
if exitCode == dotnetExitCode {
return d.language.props.getString(UnsupportedDotnetVersionIcon, "\uf071 ")
}
return version
}
2022-01-01 11:09:52 -08:00
func (d *dotnet) init(props Properties, env 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
},
},
2021-02-03 10:11:32 -08:00
versionURLTemplate: "[%1s](https://github.com/dotnet/core/blob/master/release-notes/%[2]s.%[3]s/%[2]s.%[3]s.%[4]s/%[2]s.%[3]s.%[4]s.md)",
}
}
func (d *dotnet) enabled() bool {
return d.language.enabled()
}