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

59 lines
1.1 KiB
Go
Raw Normal View History

2022-01-26 06:54:36 -08:00
package segments
2020-10-25 08:32:14 -07:00
import (
"oh-my-posh/environment"
"oh-my-posh/properties"
)
2022-01-26 05:10:18 -08:00
type Ruby struct {
2021-12-03 11:19:57 -08:00
language
2020-10-25 08:32:14 -07:00
}
func (r *Ruby) Template() string {
return languageTemplate
2020-10-25 08:32:14 -07:00
}
func (r *Ruby) Init(props properties.Properties, env environment.Environment) {
2021-12-03 11:19:57 -08:00
r.language = language{
2021-02-03 10:33:05 -08:00
env: env,
props: props,
extensions: []string{"*.rb", "Rakefile", "Gemfile"},
commands: []*cmd{
{
executable: "rbenv",
args: []string{"version-name"},
regex: `(?P<version>.+)`,
},
{
executable: "rvm-prompt",
args: []string{"i", "v", "g"},
regex: `(?P<version>.+)`,
},
{
executable: "chruby",
args: []string(nil),
regex: `\* (?P<version>.+)\n`,
},
{
executable: "asdf",
args: []string{"current", "ruby"},
regex: `ruby\s+(?P<version>[^\s]+)\s+`,
},
{
executable: "ruby",
args: []string{"--version"},
regex: `ruby\s+(?P<version>[^\s]+)\s+`,
},
},
2020-10-25 08:32:14 -07:00
}
}
func (r *Ruby) Enabled() bool {
enabled := r.language.Enabled()
// this happens when no version is set
if r.Full == "______" {
r.Full = ""
}
return enabled
2020-10-25 08:32:14 -07:00
}