From ed40fc7bf5b233de473e4a98ccce40e81108104e Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 13 Jan 2024 11:11:22 +0100 Subject: [PATCH] feat(language): cache version info --- src/mock/environment.go | 9 ++ src/platform/shell.go | 2 +- src/segments/cds_test.go | 152 +++++++++------------------ src/segments/cf_test.go | 102 ++++++------------ src/segments/dotnet_test.go | 44 +++----- src/segments/golang_test.go | 27 ----- src/segments/haskell_test.go | 27 ++--- src/segments/java_test.go | 21 ++-- src/segments/language.go | 27 +++++ src/segments/language_test.go | 68 ++++++++++++ src/segments/lua_test.go | 34 +++--- src/segments/perl_test.go | 18 ++-- src/segments/python_test.go | 28 +++-- src/segments/quasar_test.go | 25 ++--- src/segments/r_test.go | 28 ++--- src/segments/ruby_test.go | 120 ++++++++++----------- src/segments/ui5tooling_test.go | 85 ++++----------- website/docs/segments/angular.mdx | 35 +++--- website/docs/segments/azfunc.mdx | 43 ++++---- website/docs/segments/bazel.mdx | 35 +++--- website/docs/segments/buf.mdx | 31 +++--- website/docs/segments/cds.mdx | 35 +++--- website/docs/segments/cf.mdx | 37 ++++--- website/docs/segments/cmake.mdx | 37 ++++--- website/docs/segments/crystal.mdx | 37 ++++--- website/docs/segments/dart.mdx | 37 ++++--- website/docs/segments/deno.mdx | 31 +++--- website/docs/segments/elixir.mdx | 37 ++++--- website/docs/segments/flutter.mdx | 37 ++++--- website/docs/segments/golang.mdx | 39 ++++--- website/docs/segments/haskell.mdx | 39 ++++--- website/docs/segments/java.mdx | 35 +++--- website/docs/segments/julia.mdx | 37 ++++--- website/docs/segments/kotlin.mdx | 37 ++++--- website/docs/segments/lua.mdx | 39 ++++--- website/docs/segments/node.mdx | 23 ++-- website/docs/segments/npm.mdx | 37 ++++--- website/docs/segments/nx.mdx | 35 +++--- website/docs/segments/ocaml.mdx | 33 +++--- website/docs/segments/perl.mdx | 35 +++--- website/docs/segments/php.mdx | 37 ++++--- website/docs/segments/python.mdx | 41 ++++---- website/docs/segments/quasar.mdx | 17 +-- website/docs/segments/r.mdx | 37 ++++--- website/docs/segments/ruby.mdx | 35 +++--- website/docs/segments/rust.mdx | 35 +++--- website/docs/segments/swift.mdx | 37 ++++--- website/docs/segments/ui5tooling.mdx | 37 ++++--- website/docs/segments/vala.mdx | 37 ++++--- website/docs/segments/xmake.mdx | 35 +++--- 50 files changed, 1018 insertions(+), 968 deletions(-) diff --git a/src/mock/environment.go b/src/mock/environment.go index bd0ee3a2..a7bbef86 100644 --- a/src/mock/environment.go +++ b/src/mock/environment.go @@ -282,3 +282,12 @@ func (env *MockedEnvironment) SystemInfo() (*platform.SystemInfo, error) { args := env.Called() return args.Get(0).(*platform.SystemInfo), args.Error(1) } + +func (env *MockedEnvironment) Unset(name string) { + for i := 0; i < len(env.ExpectedCalls); i++ { + f := env.ExpectedCalls[i] + if f.Method == name { + f.Unset() + } + } +} diff --git a/src/platform/shell.go b/src/platform/shell.go index f5f0aa49..05f5ebfd 100644 --- a/src/platform/shell.go +++ b/src/platform/shell.go @@ -101,7 +101,7 @@ type Cache interface { // In case the ttl expired, the function returns false. Get(key string) (string, bool) // Sets a value for a given key. - // The ttl indicates how may minutes to cache the value. + // The ttl indicates how many minutes to cache the value. Set(key, value string, ttl int) // Deletes a key from the cache. Delete(key string) diff --git a/src/segments/cds_test.go b/src/segments/cds_test.go index 18d7e369..035e35bc 100644 --- a/src/segments/cds_test.go +++ b/src/segments/cds_test.go @@ -2,108 +2,77 @@ package segments import ( "fmt" - "path/filepath" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" ) func TestCdsSegment(t *testing.T) { cases := []struct { - Case string - ExpectedString string - ExpectedEnabled bool - File string - Template string - Version string - PackageJSON string - DisplayMode string + Case string + ExpectedString string + Template string + Version string + PackageJSON string + DisplayMode string }{ { - Case: "1) cds 5.5.0 - file .cdsrc.json present", - ExpectedString: "5.5.0", - ExpectedEnabled: true, - File: ".cdsrc.json", - Version: "@sap/cds: 5.5.0\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - DisplayMode: DisplayModeFiles, + Case: "1) cds 5.5.0 - file .cdsrc.json present", + ExpectedString: "5.5.0", + Version: "@sap/cds: 5.5.0\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + DisplayMode: DisplayModeFiles, }, { - Case: "2) cds 5.5.1 - file some.cds", - ExpectedString: "5.5.1", - ExpectedEnabled: true, - File: "some.cds", - Version: "@sap/cds: 5.5.1\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - DisplayMode: DisplayModeFiles, + Case: "2) cds 5.5.1 - file some.cds", + ExpectedString: "5.5.1", + Version: "@sap/cds: 5.5.1\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + DisplayMode: DisplayModeFiles, }, { - Case: "3) cds 5.5.2 - no files", - ExpectedString: "", - ExpectedEnabled: false, - DisplayMode: DisplayModeFiles, + Case: "4) cds 5.5.3 - package.json dependency", + ExpectedString: "5.5.3", + Version: "@sap/cds: 5.5.3\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", + DisplayMode: DisplayModeContext, }, { - Case: "4) cds 5.5.3 - package.json dependency", - ExpectedString: "5.5.3", - ExpectedEnabled: true, - Version: "@sap/cds: 5.5.3\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", - DisplayMode: DisplayModeContext, + Case: "4) cds 5.5.4 - package.json dependency, major + minor", + ExpectedString: "5.5", + Template: "{{ .Major }}.{{ .Minor }}", + Version: "@sap/cds: 5.5.4\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", + DisplayMode: DisplayModeContext, }, { - Case: "4) cds 5.5.4 - package.json dependency, major + minor", - ExpectedString: "5.5", - ExpectedEnabled: true, - Template: "{{ .Major }}.{{ .Minor }}", - Version: "@sap/cds: 5.5.4\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", - DisplayMode: DisplayModeContext, + Case: "6) cds 5.5.9 - display always", + ExpectedString: "5.5.9", + Version: "@sap/cds: 5.5.9\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", + DisplayMode: DisplayModeAlways, }, { - Case: "5) cds 5.5.5 - package.json present, no dependency, no files", - ExpectedString: "", - ExpectedEnabled: false, - Version: "@sap/cds: 5.5.5\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/some\": \"^5\" } }", - DisplayMode: DisplayModeContext, - }, - { - Case: "6) cds 5.5.9 - display always", - ExpectedString: "5.5.9", - ExpectedEnabled: true, - Version: "@sap/cds: 5.5.9\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - PackageJSON: "{ \"name\": \"my-app\",\"dependencies\": { \"@sap/cds\": \"^5\" } }", - DisplayMode: DisplayModeAlways, - }, - { - Case: "7) cds 5.5.9 - package.json, no dependencies section", - ExpectedString: "", - ExpectedEnabled: false, - Version: "@sap/cds: 5.5.9\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - PackageJSON: "{ \"name\": \"my-app\" }", - DisplayMode: DisplayModeContext, - }, - { - Case: "8) cds 5.5.0 - file .cdsrc-private.json present", - ExpectedString: "5.5.0", - ExpectedEnabled: true, - File: ".cdsrc-private.json", - Version: "@sap/cds: 5.5.0\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", - DisplayMode: DisplayModeFiles, + Case: "8) cds 5.5.0 - file .cdsrc-private.json present", + ExpectedString: "5.5.0", + Version: "@sap/cds: 5.5.0\n@sap/cds-compiler: 2.7.0\n@sap/cds-dk: 4.5.3", + DisplayMode: DisplayModeFiles, }, } for _, tc := range cases { - var env = new(mock.MockedEnvironment) - env.On("HasCommand", "cds").Return(true) - env.On("RunCommand", "cds", []string{"--version"}).Return(tc.Version, nil) - env.On("Pwd").Return("/usr/home/dev/my-app") - env.On("Home").Return("/usr/home") + params := &mockedLanguageParams{ + cmd: "cds", + versionParam: "--version", + versionOutput: tc.Version, + extension: ".cdsrc.json", + } + env, props := getMockedLanguageEnv(params) - if tc.PackageJSON != "" { + if len(tc.DisplayMode) == 0 { + tc.DisplayMode = DisplayModeContext + } + props[DisplayMode] = tc.DisplayMode + + if len(tc.PackageJSON) != 0 { env.On("HasFiles", "package.json").Return(true) env.On("FileContent", "package.json").Return(tc.PackageJSON) } else { @@ -111,37 +80,14 @@ func TestCdsSegment(t *testing.T) { } cds := &Cds{} - - props := properties.Map{ - "display_mode": tc.DisplayMode, - } - - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) + cds.Init(props, env) if tc.Template == "" { tc.Template = cds.Template() } - if tc.DisplayMode == "" { - tc.DisplayMode = DisplayModeContext - } - - cds.Init(props, env) - - for _, f := range cds.language.extensions { - match, err := filepath.Match(f, tc.File) - - if err != nil { - t.Fail() - } - - env.On("HasFiles", f).Return(match) - } - failMsg := fmt.Sprintf("Failed in case: %s", tc.Case) - assert.Equal(t, tc.ExpectedEnabled, cds.Enabled(), failMsg) + assert.True(t, cds.Enabled(), failMsg) assert.Equal(t, tc.ExpectedString, renderTemplate(env, tc.Template, cds), failMsg) } } diff --git a/src/segments/cf_test.go b/src/segments/cf_test.go index 768d17a9..4e89648c 100644 --- a/src/segments/cf_test.go +++ b/src/segments/cf_test.go @@ -2,102 +2,64 @@ package segments import ( "fmt" - "path/filepath" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) func TestCFSegment(t *testing.T) { cases := []struct { - Case string - Template string - ExpectedString string - ExpectedEnabled bool - CfYamlFile string - Version string - DisplayMode string + Case string + Template string + ExpectedString string + CfYamlFile string + Version string + DisplayMode string }{ { - Case: "1) cf 2.12.1 - file manifest.yml", - ExpectedString: "2.12.1", - ExpectedEnabled: true, - CfYamlFile: "manifest.yml", - Version: `cf.exe version 2.12.1+645c3ce6a.2021-08-16`, - DisplayMode: DisplayModeFiles, + Case: "1) cf 2.12.1 - file manifest.yml", + ExpectedString: "2.12.1", + CfYamlFile: "manifest.yml", + Version: `cf.exe version 2.12.1+645c3ce6a.2021-08-16`, + DisplayMode: DisplayModeFiles, }, { - Case: "2) cf 11.0.0-rc1 - file mta.yaml", - Template: "{{ .Major }}", - ExpectedString: "11", - ExpectedEnabled: true, - CfYamlFile: "mta.yaml", - Version: `cf version 11.0.0-rc1`, - DisplayMode: DisplayModeFiles, + Case: "2) cf 11.0.0-rc1 - file mta.yaml", + Template: "{{ .Major }}", + ExpectedString: "11", + CfYamlFile: "mta.yaml", + Version: `cf version 11.0.0-rc1`, + DisplayMode: DisplayModeFiles, }, { - Case: "3) cf 11.0.0-rc1 - no file", - Template: "{{ .Major }}", - ExpectedString: "", - ExpectedEnabled: false, - Version: `cf version 11.0.0-rc1`, - DisplayMode: DisplayModeFiles, - }, - { - Case: "4) cf 11.1.0-rc1 - mode always", - Template: "{{ .Major }}.{{ .Minor }}", - ExpectedString: "11.1", - ExpectedEnabled: true, - Version: `cf.exe version 11.1.0-rc1`, - DisplayMode: DisplayModeAlways, + Case: "4) cf 11.1.0-rc1 - mode always", + Template: "{{ .Major }}.{{ .Minor }}", + ExpectedString: "11.1", + Version: `cf.exe version 11.1.0-rc1`, + DisplayMode: DisplayModeAlways, }, } for _, tc := range cases { - var env = new(mock.MockedEnvironment) - env.On("HasCommand", "cf").Return(true) - env.On("RunCommand", "cf", []string{"version"}).Return(tc.Version, nil) - env.On("Pwd").Return("/usr/home/dev/my-app") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) + params := &mockedLanguageParams{ + cmd: "cf", + versionParam: "version", + versionOutput: tc.Version, + extension: "manifest.yml", + } + env, props := getMockedLanguageEnv(params) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) + props[DisplayMode] = tc.DisplayMode cf := &Cf{} - - props := properties.Map{ - DisplayMode: tc.DisplayMode, - } + cf.Init(props, env) if tc.Template == "" { tc.Template = cf.Template() } - cf.Init(props, env) - - for _, f := range cf.language.extensions { - match, err := filepath.Match(f, tc.CfYamlFile) - - if err != nil { - t.Fail() - } - - if match { - env.On("HasFiles", f).Return(true) - } else { - env.On("HasFiles", f).Return(false) - } - } - failMsg := fmt.Sprintf("Failed in case: %s", tc.Case) - assert.Equal(t, tc.ExpectedEnabled, cf.Enabled(), failMsg) + assert.True(t, cf.Enabled(), failMsg) assert.Equal(t, tc.ExpectedString, renderTemplate(env, tc.Template, cf), failMsg) } } diff --git a/src/segments/dotnet_test.go b/src/segments/dotnet_test.go index 4a9da832..01c54aff 100644 --- a/src/segments/dotnet_test.go +++ b/src/segments/dotnet_test.go @@ -4,52 +4,40 @@ import ( "testing" "github.com/jandedobbeleer/oh-my-posh/src/constants" - "github.com/jandedobbeleer/oh-my-posh/src/mock" "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) func TestDotnetSegment(t *testing.T) { cases := []struct { - Case string - Expected string - ExitCode int - HasCommand bool - Version string - FetchVersion bool + Case string + Expected string + ExitCode int + Version string }{ - {Case: "Unsupported version", Expected: "\uf071", HasCommand: true, FetchVersion: true, ExitCode: constants.DotnetExitCode, Version: "3.1.402"}, - {Case: "Regular version", Expected: "3.1.402", HasCommand: true, FetchVersion: true, Version: "3.1.402"}, - {Case: "Regular version", Expected: "", HasCommand: true, FetchVersion: false, Version: "3.1.402"}, - {Case: "Regular version", Expected: "", HasCommand: false, FetchVersion: false, Version: "3.1.402"}, + {Case: "Unsupported version", Expected: "\uf071", ExitCode: constants.DotnetExitCode, Version: "3.1.402"}, + {Case: "Regular version", Expected: "3.1.402", Version: "3.1.402"}, } for _, tc := range cases { - env := new(mock.MockedEnvironment) - env.On("HasCommand", "dotnet").Return(tc.HasCommand) + params := &mockedLanguageParams{ + cmd: "dotnet", + versionParam: "--version", + versionOutput: tc.Version, + extension: "*.cs", + } + env, props := getMockedLanguageEnv(params) + if tc.ExitCode != 0 { + env.Unset("RunCommand") err := &platform.CommandError{ExitCode: tc.ExitCode} env.On("RunCommand", "dotnet", []string{"--version"}).Return("", err) - } else { - env.On("RunCommand", "dotnet", []string{"--version"}).Return(tc.Version, nil) } - env.On("HasFiles", "*.cs").Return(true) - env.On("PathSeparator").Return("") - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - props := properties.Map{ - properties.FetchVersion: tc.FetchVersion, - } dotnet := &Dotnet{} dotnet.Init(props, env) + assert.True(t, dotnet.Enabled()) assert.Equal(t, tc.Expected, renderTemplate(env, dotnet.Template(), dotnet), tc.Case) } diff --git a/src/segments/golang_test.go b/src/segments/golang_test.go index 4374bd2d..ff6a2557 100644 --- a/src/segments/golang_test.go +++ b/src/segments/golang_test.go @@ -6,38 +6,11 @@ import ( "os" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) -type mockedLanguageParams struct { - cmd string - versionParam string - versionOutput string - extension string -} - -func getMockedLanguageEnv(params *mockedLanguageParams) (*mock.MockedEnvironment, properties.Map) { - env := new(mock.MockedEnvironment) - env.On("HasCommand", params.cmd).Return(true) - env.On("RunCommand", params.cmd, []string{params.versionParam}).Return(params.versionOutput, nil) - env.On("HasFiles", params.extension).Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - props := properties.Map{ - properties.FetchVersion: true, - } - return env, props -} - func TestGolang(t *testing.T) { cases := []struct { Case string diff --git a/src/segments/haskell_test.go b/src/segments/haskell_test.go index cb0da8e8..8e08b1c8 100644 --- a/src/segments/haskell_test.go +++ b/src/segments/haskell_test.go @@ -5,12 +5,9 @@ import ( "fmt" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) func TestHaskell(t *testing.T) { @@ -57,36 +54,32 @@ func TestHaskell(t *testing.T) { } for _, tc := range cases { - env := new(mock.MockedEnvironment) + params := &mockedLanguageParams{ + cmd: "ghc", + versionParam: "--numeric-version", + versionOutput: tc.GhcVersion, + extension: "*.hs", + } + env, props := getMockedLanguageEnv(params) + if tc.StackGhcMode == "always" || (tc.StackGhcMode == "package" && tc.InStackPackage) { env.On("HasCommand", "stack").Return(true) env.On("RunCommand", "stack", []string{"ghc", "--", "--numeric-version"}).Return(tc.StackGhcVersion, nil) - } else { - env.On("HasCommand", "ghc").Return(true) - env.On("RunCommand", "ghc", []string{"--numeric-version"}).Return(tc.GhcVersion, nil) } + fileInfo := &platform.FileInfo{ Path: "../stack.yaml", ParentFolder: "./", IsDir: false, } + if tc.InStackPackage { var err error env.On("HasParentFilePath", "stack.yaml").Return(fileInfo, err) } else { env.On("HasParentFilePath", "stack.yaml").Return(fileInfo, errors.New("no match")) } - env.On("HasFiles", "*.hs").Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - props := properties.Map{ - properties.FetchVersion: true, - } props[StackGhcMode] = tc.StackGhcMode h := &Haskell{} diff --git a/src/segments/java_test.go b/src/segments/java_test.go index d8628494..91bc3680 100644 --- a/src/segments/java_test.go +++ b/src/segments/java_test.go @@ -4,9 +4,6 @@ import ( "fmt" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" ) @@ -56,12 +53,14 @@ func TestJava(t *testing.T) { }, } for _, tc := range cases { - env := new(mock.MockedEnvironment) - env.On("HasCommand", "java").Return(true) - env.On("RunCommand", "java", []string{"-Xinternalversion"}).Return(tc.Version, nil) - env.On("HasFiles", "pom.xml").Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") + params := &mockedLanguageParams{ + cmd: "java", + versionParam: "-Xinternalversion", + versionOutput: tc.Version, + extension: "pom.xml", + } + env, props := getMockedLanguageEnv(params) + if tc.JavaHomeEnabled { env.On("Getenv", "JAVA_HOME").Return("/usr/java") env.On("HasCommand", "/usr/java/bin/java").Return(true) @@ -69,9 +68,7 @@ func TestJava(t *testing.T) { } else { env.On("Getenv", "JAVA_HOME").Return("") } - props := properties.Map{ - properties.FetchVersion: true, - } + j := &Java{} j.Init(props, env) assert.True(t, j.Enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) diff --git a/src/segments/language.go b/src/segments/language.go index 5610b5ad..84d42732 100644 --- a/src/segments/language.go +++ b/src/segments/language.go @@ -100,6 +100,8 @@ const ( LanguageExtensions properties.Property = "extensions" // LanguageFolders the list of folders to validate LanguageFolders properties.Property = "folders" + // CacheVersion allows caching the version number + CacheVersion properties.Property = "cache_version" ) func (l *language) Enabled() bool { @@ -192,14 +194,29 @@ func (l *language) hasLanguageFolders() bool { // setVersion parses the version string returned by the command func (l *language) setVersion() error { var lastError error + cacheVersion := l.props.GetBool(CacheVersion, false) + for _, command := range l.commands { var versionStr string var err error + + versionKey := fmt.Sprintf("%s_version", command.executable) + versionURL := fmt.Sprintf("%s_version_url", command.executable) + + if versionStr, OK := l.env.Cache().Get(versionKey); OK { + version, _ := command.parse(versionStr) + l.version = *version + l.version.Executable = command.executable + l.version.URL, _ = l.env.Cache().Get(versionURL) + return nil + } + if command.getVersion == nil { if !l.env.HasCommand(command.executable) { lastError = errors.New(noVersion) continue } + versionStr, err = l.env.RunCommand(command.executable, command.args...) if exitErr, ok := err.(*platform.CommandError); ok { l.exitCode = exitErr.ExitCode @@ -213,17 +230,27 @@ func (l *language) setVersion() error { continue } } + version, err := command.parse(versionStr) if err != nil { lastError = fmt.Errorf("err parsing info from %s with %s", command.executable, versionStr) continue } + l.version = *version if command.versionURLTemplate != "" { l.versionURLTemplate = command.versionURLTemplate } + l.buildVersionURL() l.version.Executable = command.executable + + if cacheVersion { + timeout := l.props.GetInt(properties.CacheTimeout, 1440) + l.env.Cache().Set(versionKey, versionStr, timeout) + l.env.Cache().Set(versionURL, l.version.URL, timeout) + } + return nil } if lastError != nil { diff --git a/src/segments/language_test.go b/src/segments/language_test.go index 4161b0ae..67ba9ddf 100644 --- a/src/segments/language_test.go +++ b/src/segments/language_test.go @@ -28,6 +28,7 @@ type languageArgs struct { properties properties.Properties matchesVersionFile matchesVersionFile inHome bool + cachedVersion string } func (l *languageArgs) hasvalue(value string, list []string) bool { @@ -41,27 +42,38 @@ func (l *languageArgs) hasvalue(value string, list []string) bool { func bootStrapLanguageTest(args *languageArgs) *language { env := new(mock.MockedEnvironment) + for _, command := range args.commands { env.On("HasCommand", command.executable).Return(args.hasvalue(command.executable, args.enabledCommands)) env.On("RunCommand", command.executable, command.args).Return(args.version, args.expectedError) } + for _, extension := range args.extensions { env.On("HasFiles", extension).Return(args.hasvalue(extension, args.enabledExtensions)) } + home := "/usr/home" cwd := "/usr/home/project" if args.inHome { cwd = home } + env.On("Pwd").Return(cwd) env.On("Home").Return(home) env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) env.On("TemplateCache").Return(&platform.TemplateCache{ Env: make(map[string]string), }) + + cache := &mock.MockedCache{} + cache.On("Get", mock2.Anything).Return(args.cachedVersion, len(args.cachedVersion) > 0) + cache.On("Set", mock2.Anything, mock2.Anything, mock2.Anything) + env.On("Cache").Return(cache) + if args.properties == nil { args.properties = properties.Map{} } + l := &language{ props: args.properties, env: env, @@ -70,6 +82,7 @@ func bootStrapLanguageTest(args *languageArgs) *language { versionURLTemplate: args.versionURLTemplate, matchesVersionFile: args.matchesVersionFile, } + return l } @@ -524,3 +537,58 @@ func TestLanguageHyperlinkTemplatePropertyTakesPriority(t *testing.T) { assert.True(t, lang.Enabled()) assert.Equal(t, "https://custom/url/template/1.3", lang.version.URL) } + +func TestLanguageEnabledCachedVersion(t *testing.T) { + props := properties.Map{ + properties.FetchVersion: true, + } + args := &languageArgs{ + commands: []*cmd{ + { + executable: "unicorn", + args: []string{"--version"}, + regex: "(?P.*)", + }, + }, + extensions: []string{uni, corn}, + enabledExtensions: []string{uni, corn}, + enabledCommands: []string{"unicorn"}, + version: universion, + cachedVersion: "1.3.37", + properties: props, + } + lang := bootStrapLanguageTest(args) + assert.True(t, lang.Enabled()) + assert.Equal(t, "1.3.37", lang.Full, "cached unicorn version is available") + assert.Equal(t, "unicorn", lang.Executable, "cached version was found") +} + +type mockedLanguageParams struct { + cmd string + versionParam string + versionOutput string + extension string +} + +func getMockedLanguageEnv(params *mockedLanguageParams) (*mock.MockedEnvironment, properties.Map) { + env := new(mock.MockedEnvironment) + env.On("HasCommand", params.cmd).Return(true) + env.On("RunCommand", params.cmd, []string{params.versionParam}).Return(params.versionOutput, nil) + env.On("HasFiles", params.extension).Return(true) + env.On("Pwd").Return("/usr/home/project") + env.On("Home").Return("/usr/home") + env.On("TemplateCache").Return(&platform.TemplateCache{ + Env: make(map[string]string), + }) + env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) + props := properties.Map{ + properties.FetchVersion: true, + } + + cache := &mock.MockedCache{} + cache.On("Get", mock2.Anything).Return("", false) + cache.On("Set", mock2.Anything, mock2.Anything, mock2.Anything) + env.On("Cache").Return(cache) + + return env, props +} diff --git a/src/segments/lua_test.go b/src/segments/lua_test.go index e80bc0a2..28ea66b8 100644 --- a/src/segments/lua_test.go +++ b/src/segments/lua_test.go @@ -5,12 +5,7 @@ import ( "strings" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) func TestLua(t *testing.T) { @@ -59,24 +54,27 @@ func TestLua(t *testing.T) { }, } for _, tc := range cases { - env := new(mock.MockedEnvironment) - env.On("HasCommand", "lua").Return(tc.HasLua) - env.On("RunCommand", "lua", []string{"-v"}).Return(tc.Version, nil) + params := &mockedLanguageParams{ + cmd: "lua", + versionParam: "-v", + versionOutput: tc.Version, + extension: "*.lua", + } + env, props := getMockedLanguageEnv(params) + + if !tc.HasLua { + env.Unset("HasCommand") + env.On("HasCommand", "lua").Return(false) + } + env.On("HasCommand", "luajit").Return(tc.HasLuaJit) env.On("RunCommand", "luajit", []string{"-v"}).Return(tc.Version, nil) - env.On("HasFiles", "*.lua").Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - props := properties.Map{ - properties.FetchVersion: true, - } + props[PreferredExecutable] = tc.Prefer + l := &Lua{} l.Init(props, env) + failMsg := fmt.Sprintf("Failed in case: %s", tc.Case) assert.True(t, l.Enabled(), failMsg) assert.Equal(t, tc.ExpectedString, renderTemplate(env, l.Template(), l), failMsg) diff --git a/src/segments/perl_test.go b/src/segments/perl_test.go index a16ff0d5..dc448324 100644 --- a/src/segments/perl_test.go +++ b/src/segments/perl_test.go @@ -4,9 +4,6 @@ import ( "fmt" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" ) @@ -30,15 +27,14 @@ func TestPerl(t *testing.T) { }, } for _, tc := range cases { - env := new(mock.MockedEnvironment) - env.On("HasCommand", "perl").Return(true) - env.On("RunCommand", "perl", []string{"-version"}).Return(tc.Version, nil) - env.On("HasFiles", ".perl-version").Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - props := properties.Map{ - properties.FetchVersion: true, + params := &mockedLanguageParams{ + cmd: "perl", + versionParam: "-version", + versionOutput: tc.Version, + extension: ".perl-version", } + env, props := getMockedLanguageEnv(params) + p := &Perl{} p.Init(props, env) assert.True(t, p.Enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) diff --git a/src/segments/python_test.go b/src/segments/python_test.go index e243fad1..c5794d0e 100644 --- a/src/segments/python_test.go +++ b/src/segments/python_test.go @@ -90,13 +90,17 @@ func TestPythonTemplate(t *testing.T) { } for _, tc := range cases { - env := new(mock.MockedEnvironment) + params := &mockedLanguageParams{ + cmd: "python", + versionParam: "--version", + versionOutput: "Python 3.8.4", + extension: "*.py", + } + env, props := getMockedLanguageEnv(params) + env.On("GOOS").Return("") - env.On("HasCommand", "python").Return(true) env.On("CommandPath", mock2.Anything).Return(tc.PythonPath) - env.On("RunCommand", "python", []string{"--version"}).Return("Python 3.8.4", nil) env.On("RunCommand", "pyenv", []string{"version-name"}).Return(tc.VirtualEnvName, nil) - env.On("HasFiles", "*.py").Return(true) env.On("HasFilesInDir", mock2.Anything, "pyvenv.cfg").Return(len(tc.PyvenvCfg) > 0) env.On("FileContent", filepath.Join(filepath.Dir(tc.PythonPath), "pyvenv.cfg")).Return(tc.PyvenvCfg) env.On("Getenv", "VIRTUAL_ENV").Return(tc.VirtualEnvName) @@ -104,18 +108,12 @@ func TestPythonTemplate(t *testing.T) { env.On("Getenv", "CONDA_DEFAULT_ENV").Return(tc.VirtualEnvName) env.On("Getenv", "PYENV_ROOT").Return("/home/user/.pyenv") env.On("PathSeparator").Return("") - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") env.On("ResolveSymlink", mock2.Anything).Return(tc.ResolveSymlink.Path, tc.ResolveSymlink.Err) - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - props := properties.Map{ - properties.FetchVersion: tc.FetchVersion, - UsePythonVersionFile: true, - DisplayMode: DisplayModeAlways, - } - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) + + props[properties.FetchVersion] = tc.FetchVersion + props[UsePythonVersionFile] = true + props[DisplayMode] = DisplayModeAlways + python := &Python{} python.Init(props, env) assert.Equal(t, !tc.ExpectedDisabled, python.Enabled(), tc.Case) diff --git a/src/segments/quasar_test.go b/src/segments/quasar_test.go index c7c5dfff..fc4bc815 100644 --- a/src/segments/quasar_test.go +++ b/src/segments/quasar_test.go @@ -6,10 +6,7 @@ import ( "testing" "github.com/alecthomas/assert" - "github.com/jandedobbeleer/oh-my-posh/src/mock" "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - mock2 "github.com/stretchr/testify/mock" ) func TestQuasar(t *testing.T) { @@ -58,24 +55,20 @@ func TestQuasar(t *testing.T) { }, } for _, tc := range cases { - env := new(mock.MockedEnvironment) - env.On("HasCommand", "quasar").Return(true) - env.On("RunCommand", "quasar", []string{"--version"}).Return(tc.Version, nil) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) + params := &mockedLanguageParams{ + cmd: "quasar", + versionParam: "--version", + versionOutput: tc.Version, + extension: "quasar.config", + } + env, props := getMockedLanguageEnv(params) + env.On("HasFilesInDir", "/usr/home/project", "package-lock.json").Return(tc.HasPackageLockFile) fileInfo := &platform.FileInfo{ParentFolder: "/usr/home/project", IsDir: true} env.On("HasParentFilePath", "quasar.config").Return(fileInfo, nil) env.On("FileContent", filepath.Join(fileInfo.ParentFolder, "package-lock.json")).Return(packageLockFile) - props := properties.Map{ - properties.FetchVersion: true, - FetchDependencies: tc.FetchDependencies, - } + props[FetchDependencies] = tc.FetchDependencies quasar := &Quasar{} quasar.Init(props, env) diff --git a/src/segments/r_test.go b/src/segments/r_test.go index 32186761..79ebf32c 100644 --- a/src/segments/r_test.go +++ b/src/segments/r_test.go @@ -4,12 +4,7 @@ import ( "fmt" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" - "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) func TestR(t *testing.T) { @@ -36,25 +31,22 @@ func TestR(t *testing.T) { {Case: "R.exe 4.0.0", ExpectedString: "4.0.0", HasRexe: true, Version: "R version 4.0.0 (2020-04-24) -- \"Arbor Day\""}, } for _, tc := range cases { - env := new(mock.MockedEnvironment) + params := &mockedLanguageParams{ + cmd: "R", + versionParam: "--version", + versionOutput: tc.Version, + extension: "*.R", + } + env, props := getMockedLanguageEnv(params) + env.On("HasCommand", "Rscript").Return(tc.HasRscript) env.On("RunCommand", "Rscript", []string{"--version"}).Return(tc.Version, nil) - env.On("HasCommand", "R").Return(tc.HasR) - env.On("RunCommand", "R", []string{"--version"}).Return(tc.Version, nil) env.On("HasCommand", "R.exe").Return(tc.HasRexe) env.On("RunCommand", "R.exe", []string{"--version"}).Return(tc.Version, nil) - env.On("HasFiles", "*.R").Return(true) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - props := properties.Map{ - properties.FetchVersion: true, - } + r := &R{} r.Init(props, env) + assert.True(t, r.Enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) assert.Equal(t, tc.ExpectedString, renderTemplate(env, r.Template(), r), fmt.Sprintf("Failed in case: %s", tc.Case)) } diff --git a/src/segments/ruby_test.go b/src/segments/ruby_test.go index 9b9482a3..43facf97 100644 --- a/src/segments/ruby_test.go +++ b/src/segments/ruby_test.go @@ -4,7 +4,6 @@ import ( "fmt" "testing" - "github.com/jandedobbeleer/oh-my-posh/src/mock" "github.com/jandedobbeleer/oh-my-posh/src/properties" "github.com/stretchr/testify/assert" @@ -12,80 +11,79 @@ import ( func TestRuby(t *testing.T) { cases := []struct { - Case string - ExpectedString string - ExpectedEnabled bool - HasRbenv bool - HasRvmprompt bool - HasChruby bool - HasAsdf bool - HasRuby bool - Version string - HasRubyFiles bool - HasRakeFile bool - HasGemFile bool - FetchVersion bool + Case string + ExpectedString string + HasRbenv bool + HasRvmprompt bool + HasChruby bool + HasAsdf bool + HasRuby bool + Version string + HasRubyFiles bool + HasRakeFile bool + HasGemFile bool + FetchVersion bool }{ - {Case: "No files", ExpectedString: "", ExpectedEnabled: false}, - {Case: "Ruby files", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasRubyFiles: true}, - {Case: "Rakefile", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasRakeFile: true}, - {Case: "Gemfile", ExpectedString: "", ExpectedEnabled: true, FetchVersion: false, HasGemFile: true}, - {Case: "Gemfile with version", ExpectedString: noVersion, ExpectedEnabled: true, FetchVersion: true, HasGemFile: true}, - {Case: "No files with version", ExpectedString: "", ExpectedEnabled: false, FetchVersion: true}, + {Case: "Ruby files", ExpectedString: "", FetchVersion: false, HasRubyFiles: true}, + {Case: "Rakefile", ExpectedString: "", FetchVersion: false, HasRakeFile: true}, + {Case: "Gemfile", ExpectedString: "", FetchVersion: false, HasGemFile: true}, + {Case: "Gemfile with version", ExpectedString: "err parsing info from ruby with", FetchVersion: true, HasGemFile: true}, { - Case: "Version with chruby", - ExpectedString: "ruby-2.6.3", - ExpectedEnabled: true, - FetchVersion: true, - HasRubyFiles: true, - HasChruby: true, + Case: "Version with chruby", + ExpectedString: "ruby-2.6.3", + FetchVersion: true, + HasRubyFiles: true, + HasChruby: true, Version: ` * ruby-2.6.3 ruby-1.9.3-p392 jruby-1.7.0 rubinius-2.0.0-rc1`, }, { - Case: "Version with chruby line 2", - ExpectedString: "ruby-1.9.3-p392", - ExpectedEnabled: true, - FetchVersion: true, - HasRubyFiles: true, - HasChruby: true, + Case: "Version with chruby line 2", + ExpectedString: "ruby-1.9.3-p392", + FetchVersion: true, + HasRubyFiles: true, + HasChruby: true, Version: ` ruby-2.6.3 * ruby-1.9.3-p392 jruby-1.7.0 rubinius-2.0.0-rc1`, }, { - Case: "Version with asdf", - ExpectedString: "2.6.3", - ExpectedEnabled: true, - FetchVersion: true, - HasRubyFiles: true, - HasAsdf: true, - Version: "ruby 2.6.3 /Users/jan/Projects/oh-my-posh/.tool-versions", + Case: "Version with asdf", + ExpectedString: "2.6.3", + FetchVersion: true, + HasRubyFiles: true, + HasAsdf: true, + Version: "ruby 2.6.3 /Users/jan/Projects/oh-my-posh/.tool-versions", }, { - Case: "Version with asdf not set", - ExpectedString: "", - ExpectedEnabled: true, - FetchVersion: true, - HasRubyFiles: true, - HasAsdf: true, - Version: "ruby ______ No version set. Run \"asdf ruby \"", + Case: "Version with asdf not set", + ExpectedString: "", + FetchVersion: true, + HasRubyFiles: true, + HasAsdf: true, + Version: "ruby ______ No version set. Run \"asdf ruby \"", }, { - Case: "Version with ruby", - ExpectedString: "2.6.3", - ExpectedEnabled: true, - FetchVersion: true, - HasRubyFiles: true, - HasRuby: true, - Version: "ruby 2.6.3 (2019-04-16 revision 67580) [universal.x86_64-darwin20]", + Case: "Version with ruby", + ExpectedString: "2.6.3", + FetchVersion: true, + HasRubyFiles: true, + HasRuby: true, + Version: "ruby 2.6.3 (2019-04-16 revision 67580) [universal.x86_64-darwin20]", }, } for _, tc := range cases { - env := new(mock.MockedEnvironment) + params := &mockedLanguageParams{ + cmd: "ruby", + versionParam: "--version", + versionOutput: tc.Version, + extension: "*.rb", + } + env, props := getMockedLanguageEnv(params) + env.On("HasCommand", "rbenv").Return(tc.HasRbenv) env.On("RunCommand", "rbenv", []string{"version-name"}).Return(tc.Version, nil) env.On("HasCommand", "rvm-prompt").Return(tc.HasRvmprompt) @@ -94,19 +92,15 @@ func TestRuby(t *testing.T) { env.On("RunCommand", "chruby", []string(nil)).Return(tc.Version, nil) env.On("HasCommand", "asdf").Return(tc.HasAsdf) env.On("RunCommand", "asdf", []string{"current", "ruby"}).Return(tc.Version, nil) - env.On("HasCommand", "ruby").Return(tc.HasRuby) - env.On("RunCommand", "ruby", []string{"--version"}).Return(tc.Version, nil) - env.On("HasFiles", "*.rb").Return(tc.HasRubyFiles) env.On("HasFiles", "Rakefile").Return(tc.HasRakeFile) env.On("HasFiles", "Gemfile").Return(tc.HasGemFile) - env.On("Pwd").Return("/usr/home/project") - env.On("Home").Return("/usr/home") - props := properties.Map{ - properties.FetchVersion: tc.FetchVersion, - } + + props[properties.FetchVersion] = tc.FetchVersion + ruby := &Ruby{} ruby.Init(props, env) - assert.Equal(t, tc.ExpectedEnabled, ruby.Enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) + + assert.True(t, ruby.Enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) assert.Equal(t, tc.ExpectedString, renderTemplate(env, ruby.Template(), ruby), fmt.Sprintf("Failed in case: %s", tc.Case)) } } diff --git a/src/segments/ui5tooling_test.go b/src/segments/ui5tooling_test.go index c47ceb92..370b7807 100644 --- a/src/segments/ui5tooling_test.go +++ b/src/segments/ui5tooling_test.go @@ -6,11 +6,8 @@ import ( "testing" "github.com/jandedobbeleer/oh-my-posh/src/mock" - "github.com/jandedobbeleer/oh-my-posh/src/platform" - "github.com/jandedobbeleer/oh-my-posh/src/properties" "github.com/stretchr/testify/assert" - mock2 "github.com/stretchr/testify/mock" ) const ( @@ -21,7 +18,6 @@ type testCase struct { Case string Template string ExpectedString string - ExpectedEnabled bool UI5YamlFilename string WorkingDir string Version string @@ -33,7 +29,6 @@ func TestUI5Tooling(t *testing.T) { { Case: "1) ui5tooling 2.12.1 - file ui5.yaml present in cwd; DisplayMode = files", ExpectedString: "2.12.1", - ExpectedEnabled: true, UI5YamlFilename: "ui5.yaml", Version: `2.12.1 (from C:\somewhere\cli\bin\ui5.js)`, DisplayMode: DisplayModeFiles, @@ -41,7 +36,6 @@ func TestUI5Tooling(t *testing.T) { { Case: "2) ui5tooling 2.12.2 - file ui5.yaml present in cwd; default display mode (context)", ExpectedString: "2.12.2", - ExpectedEnabled: true, UI5YamlFilename: "ui5.yaml", Version: `2.12.2 (from C:\somewhere\cli\bin\ui5.js)`, }, @@ -49,98 +43,59 @@ func TestUI5Tooling(t *testing.T) { Case: "3) ui5tooling 2.12.3 - file ui5.yaml present; cwd is sub dir, default display mode (context)", ExpectedString: "2.12.3", WorkingDir: WorkingDirRoot + "/subdir", - ExpectedEnabled: true, UI5YamlFilename: "ui5.yaml", Version: `2.12.3 (from C:\somewhere\cli\bin\ui5.js)`, }, - { - Case: "4) no ui5tooling segment - file ui5.yaml present, cwd is sub dir; display mode = files", - ExpectedString: "", - WorkingDir: WorkingDirRoot + "/subdir", - ExpectedEnabled: false, - UI5YamlFilename: "ui5.yaml", - DisplayMode: DisplayModeFiles, - Version: `2.12.1 (from C:\somewhere\cli\bin\ui5.js)`, - }, { Case: "5) ui5tooling 2.12.4 - file ui5-dist.yml present in cwd", ExpectedString: "2.12.4", - ExpectedEnabled: true, UI5YamlFilename: "ui5-dist.yml", Version: `2.12.4 (from C:\somewhere\cli\bin\ui5.js)`, DisplayMode: DisplayModeFiles, }, { - Case: "6) no ui5tooling segment - file ui5.yaml not present, display mode = files", - ExpectedString: "", - ExpectedEnabled: false, - Version: `2.12.1 (from C:\somewhere\cli\bin\ui5.js)`, - DisplayMode: DisplayModeFiles, - }, - { - Case: "7) no ui5tooling segment - file ui5.yaml not present, default display mode (context)", - ExpectedString: "", - ExpectedEnabled: false, - Version: `2.12.1 (from C:\somewhere\cli\bin\ui5.js)`, - }, - { - Case: "8) ui5tooling 11.0.0-rc1, no ui5.yaml file but display mode = always", - Template: "{{ .Major }}", - ExpectedString: "11", - ExpectedEnabled: true, - Version: `11.0.0-rc1 (from C:\somewhere\cli\bin\ui5.js)`, - DisplayMode: DisplayModeAlways, + Case: "8) ui5tooling 11.0.0-rc1, no ui5.yaml file but display mode = always", + Template: "{{ .Major }}", + ExpectedString: "11", + Version: `11.0.0-rc1 (from C:\somewhere\cli\bin\ui5.js)`, + DisplayMode: DisplayModeAlways, }, } for _, tc := range cases { - env := prepareMockedEnvironment(&tc) - ui5tooling := &UI5Tooling{} - - if tc.WorkingDir == "" { - tc.WorkingDir = WorkingDirRoot + params := &mockedLanguageParams{ + cmd: "ui5", + versionParam: "--version", + versionOutput: tc.Version, + extension: UI5ToolingYamlPattern, } + env, props := getMockedLanguageEnv(params) - if tc.DisplayMode == "" { + if len(tc.DisplayMode) == 0 { tc.DisplayMode = DisplayModeContext } - if tc.Template == "" { - tc.Template = ui5tooling.Template() - } - - props := properties.Map{ - DisplayMode: tc.DisplayMode, - } + props[DisplayMode] = tc.DisplayMode + ui5tooling := &UI5Tooling{} ui5tooling.Init(props, env) + err := mockFilePresence(&tc, ui5tooling, env) if err != nil { t.Fail() } + if len(tc.Template) == 0 { + tc.Template = ui5tooling.Template() + } + failMsg := fmt.Sprintf("Failed in case: %s", tc.Case) - assert.Equal(t, tc.ExpectedEnabled, ui5tooling.Enabled(), failMsg) + assert.True(t, ui5tooling.Enabled(), failMsg) assert.Equal(t, tc.ExpectedString, renderTemplate(env, tc.Template, ui5tooling), failMsg) } } -func prepareMockedEnvironment(tc *testCase) *mock.MockedEnvironment { - var env = new(mock.MockedEnvironment) - env.On("HasCommand", "ui5").Return(true) - env.On("RunCommand", "ui5", []string{"--version"}).Return(tc.Version, nil) - env.On("Home").Return("/home/user") - env.On("Pwd").Return(WorkingDirRoot) - env.On("DebugF", mock2.Anything, mock2.Anything).Return(nil) - - env.On("TemplateCache").Return(&platform.TemplateCache{ - Env: make(map[string]string), - }) - - return env -} - func mockFilePresence(tc *testCase, ui5tooling *UI5Tooling, env *mock.MockedEnvironment) error { for _, f := range ui5tooling.language.extensions { match, err := filepath.Match(f, tc.UI5YamlFilename) diff --git a/website/docs/segments/angular.mdx b/website/docs/segments/angular.mdx index ba1cbb5d..8fd32783 100644 --- a/website/docs/segments/angular.mdx +++ b/website/docs/segments/angular.mdx @@ -10,25 +10,30 @@ Display the currently active [Angular CLI][angular-cli-docs] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `ng` | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `angular.json` file is present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `ng` | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `angular.json` file is present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/azfunc.mdx b/website/docs/segments/azfunc.mdx index ff242cb1..4706e1ff 100644 --- a/website/docs/segments/azfunc.mdx +++ b/website/docs/segments/azfunc.mdx @@ -10,29 +10,34 @@ Display the currently active [Azure Functions CLI][az-func-core-tools] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the Azure Functions CLI version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `host.json` or `local.settings.json` files is present (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the Azure Functions CLI version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `host.json` or `local.settings.json` files is present (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/bazel.mdx b/website/docs/segments/bazel.mdx index 84629d62..be7d2133 100644 --- a/website/docs/segments/bazel.mdx +++ b/website/docs/segments/bazel.mdx @@ -12,24 +12,29 @@ Display the currently active [Bazel][bazel-github] version. import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the Bazel version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.bazel`, `*.bzl`, `.bazelrc`, `.bazelversion`, `BUILD` or `WORKSPACE` files or any of Bazel's output folders are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info documentation | -| `icon` | `string` | the icon for the segment - defaults to `"\ue63a"` | +| Name | Type | Description | +| ---------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the Bazel version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.bazel`, `*.bzl`, `.bazelrc`, `.bazelversion`, `BUILD` or `WORKSPACE` files or any of Bazel's output folders are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info documentation | +| `icon` | `string` | the icon for the segment - defaults to `"\ue63a"` | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/buf.mdx b/website/docs/segments/buf.mdx index 9fd4e6f7..e2e867df 100644 --- a/website/docs/segments/buf.mdx +++ b/website/docs/segments/buf.mdx @@ -10,23 +10,28 @@ Display the currently active [Buf CLI][buf-docs] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `buf` | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `buf.yaml`, `buf.gen.yaml` or `buf.work.yaml` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `buf` | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `buf.yaml`, `buf.gen.yaml` or `buf.work.yaml` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/cds.mdx b/website/docs/segments/cds.mdx index 3130a990..35d5e4a9 100644 --- a/website/docs/segments/cds.mdx +++ b/website/docs/segments/cds.mdx @@ -10,25 +10,30 @@ Display the active [CDS CLI][sap-cap-cds] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the CDS version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the cds command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is displayed when `.cdsrc.json`, `.cdsrc-private` or `*.cds` file is present
  • `context`: the segment is displayed when conditions from `files` mode are fulfilled or `package.json` file is present and `@sap/cds` is in `dependencies` section (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the CDS version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the cds command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is displayed when `.cdsrc.json`, `.cdsrc-private` or `*.cds` file is present
  • `context`: the segment is displayed when conditions from `files` mode are fulfilled or `package.json` file is present and `@sap/cds` is in `dependencies` section (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/cf.mdx b/website/docs/segments/cf.mdx index 18c398f7..cd8361ce 100644 --- a/website/docs/segments/cf.mdx +++ b/website/docs/segments/cf.mdx @@ -10,26 +10,31 @@ Display the active [Cloud Foundry CLI][cloud-foundry] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the Cloud Foundry CLI version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is displayed when `manifest.yml` or `mta.yaml` file is present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the Cloud Foundry CLI version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is displayed when `manifest.yml` or `mta.yaml` file is present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/cmake.mdx b/website/docs/segments/cmake.mdx index e606605e..4a7f07ed 100644 --- a/website/docs/segments/cmake.mdx +++ b/website/docs/segments/cmake.mdx @@ -10,26 +10,31 @@ Display the currently active [Cmake][cmake-github] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the cmake version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.cmake` or `CMakeLists.txt` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the cmake version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.cmake` or `CMakeLists.txt` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/crystal.mdx b/website/docs/segments/crystal.mdx index 243093e7..f166f96e 100644 --- a/website/docs/segments/crystal.mdx +++ b/website/docs/segments/crystal.mdx @@ -10,26 +10,31 @@ Display the currently active crystal version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the julia version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.cr` or `shard.yml` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the julia version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.cr` or `shard.yml` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/dart.mdx b/website/docs/segments/dart.mdx index ada38117..26dc7205 100644 --- a/website/docs/segments/dart.mdx +++ b/website/docs/segments/dart.mdx @@ -10,26 +10,31 @@ Display the currently active dart version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the dart version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool` folder are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the dart version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool` folder are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/deno.mdx b/website/docs/segments/deno.mdx index 871354f6..013591c2 100644 --- a/website/docs/segments/deno.mdx +++ b/website/docs/segments/deno.mdx @@ -10,23 +10,28 @@ Display the currently active [Deno CLI][deno-docs] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `deno` | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.ts*`, `*.js` or `deno.json` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `deno` | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.ts*`, `*.js` or `deno.json` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/elixir.mdx b/website/docs/segments/elixir.mdx index 572f973f..18a49109 100644 --- a/website/docs/segments/elixir.mdx +++ b/website/docs/segments/elixir.mdx @@ -10,26 +10,31 @@ Display the currently active elixir version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the elixir version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.ex` or `*.exs` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the elixir version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.ex` or `*.exs` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/flutter.mdx b/website/docs/segments/flutter.mdx index f4124437..1714258d 100644 --- a/website/docs/segments/flutter.mdx +++ b/website/docs/segments/flutter.mdx @@ -10,26 +10,31 @@ Display the currently active flutter version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the flutter version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool` folder are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the flutter version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.dart`, `pubspec.yaml`, `pubspec.yml`, `pubspec.lock` files or the `.dart_tool` folder are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/golang.mdx b/website/docs/segments/golang.mdx index c925f47f..b408340f 100644 --- a/website/docs/segments/golang.mdx +++ b/website/docs/segments/golang.mdx @@ -10,27 +10,32 @@ Display the currently active golang version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the golang version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.go` or `go.mod` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | -| `parse_mod_file` | `boolean` | parse the go.mod file instead of calling `go version` | +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the golang version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.go` or `go.mod` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `parse_mod_file` | `boolean` | parse the go.mod file instead of calling `go version` | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/haskell.mdx b/website/docs/segments/haskell.mdx index 3e2798a0..f00d8ea2 100644 --- a/website/docs/segments/haskell.mdx +++ b/website/docs/segments/haskell.mdx @@ -10,27 +10,32 @@ Display the currently active Glasgow Haskell Compiler (GHC) version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the GHC version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.hs`, `*.lhs`, `stack.yaml`, `package.yaml`, `*.cabal`, or `cabal.project` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | -| `stack_ghc_mode` | `string` | determines when to use `stack ghc` to retrieve the version information. Using `stack ghc` will decrease performance.
  • `never`: never use `stack ghc` (**default**)
  • `package`: only use `stack ghc` when `stack.yaml` is in the root of the
  • `always`: always use `stack ghc`
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the GHC version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.hs`, `*.lhs`, `stack.yaml`, `package.yaml`, `*.cabal`, or `cabal.project` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `stack_ghc_mode` | `string` | determines when to use `stack ghc` to retrieve the version information. Using `stack ghc` will decrease performance.
  • `never`: never use `stack ghc` (**default**)
  • `package`: only use `stack ghc` when `stack.yaml` is in the root of the
  • `always`: always use `stack ghc`
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/java.mdx b/website/docs/segments/java.mdx index a6076e18..80d34f30 100644 --- a/website/docs/segments/java.mdx +++ b/website/docs/segments/java.mdx @@ -10,25 +10,30 @@ Display the currently active java version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the java version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present
    • `pom.xml`
    • `build.gradle.kts`
    • `build.sbt`
    • `.java-version`
    • `.deps.edn`
    • `project.clj`
    • `build.boot`
    • `*.java`
    • `*.class`
    • `*.gradle`
    • `*.jar`
    • `*.clj`
    • `*.cljc`
| +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the java version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present
    • `pom.xml`
    • `build.gradle.kts`
    • `build.sbt`
    • `.java-version`
    • `.deps.edn`
    • `project.clj`
    • `build.boot`
    • `*.java`
    • `*.class`
    • `*.gradle`
    • `*.jar`
    • `*.clj`
    • `*.cljc`
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/julia.mdx b/website/docs/segments/julia.mdx index 29ecd53c..4d682889 100644 --- a/website/docs/segments/julia.mdx +++ b/website/docs/segments/julia.mdx @@ -10,26 +10,31 @@ Display the currently active julia version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the julia version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.jl` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the julia version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.jl` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/kotlin.mdx b/website/docs/segments/kotlin.mdx index 98fa2843..c8a37673 100644 --- a/website/docs/segments/kotlin.mdx +++ b/website/docs/segments/kotlin.mdx @@ -10,26 +10,31 @@ Display the currently active [Kotlin][kotlin] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; -K {{ .Full }} " -}}/> +K {{ .Full }} ", + }} +/> ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the kotlin version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.kt`, `*.kts` or `*.ktm` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the kotlin version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.kt`, `*.kts` or `*.ktm` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/lua.mdx b/website/docs/segments/lua.mdx index f836971f..b8381afd 100644 --- a/website/docs/segments/lua.mdx +++ b/website/docs/segments/lua.mdx @@ -10,27 +10,32 @@ Display the currently active [Lua][lua] or [LuaJIT][luajit] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the lua version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.lua`, `*.rockspec` files or the `lua` folder are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | -| `preferred_executable` | `string` | the preferred executable to use when fetching the version
  • `lua`: the Lua executable (**default**)
  • `luajit`: the LuaJIT executable
| +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the lua version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.lua`, `*.rockspec` files or the `lua` folder are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `preferred_executable` | `string` | the preferred executable to use when fetching the version
  • `lua`: the Lua executable (**default**)
  • `luajit`: the LuaJIT executable
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/node.mdx b/website/docs/segments/node.mdx index 3e2b1084..bcbd6e7a 100644 --- a/website/docs/segments/node.mdx +++ b/website/docs/segments/node.mdx @@ -25,16 +25,19 @@ import Config from "@site/src/components/Config.js"; ## Properties -| Name | Type | Description | -| ----------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the Node.js version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: The segment is always displayed
  • `files`: The segment is only displayed when one of the following files is present (**default**):
    • `*.js`
    • `*.ts`
    • `package.json`
    • `.nvmrc`
    • `pnpm-workspace.yaml`
    • `.pnpmfile.cjs`
    • `.npmrc`
    • `.vue`
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | -| `fetch_package_manager` | `boolean` | define if the current project uses Yarn or NPM - defaults to `false` | -| `yarn_icon` | `string` | the icon/text to display when using Yarn - defaults to ` \uF011B` | -| `npm_icon` | `string` | the icon/text to display when using NPM - defaults to ` \uE71E` | +| Name | Type | Description | +| ----------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the Node.js version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: The segment is always displayed
  • `files`: The segment is only displayed when one of the following files is present (**default**):
    • `*.js`
    • `*.ts`
    • `package.json`
    • `.nvmrc`
    • `pnpm-workspace.yaml`
    • `.pnpmfile.cjs`
    • `.npmrc`
    • `.vue`
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `fetch_package_manager` | `boolean` | define if the current project uses Yarn or NPM - defaults to `false` | +| `yarn_icon` | `string` | the icon/text to display when using Yarn - defaults to ` \uF011B` | +| `npm_icon` | `string` | the icon/text to display when using NPM - defaults to ` \uE71E` | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/npm.mdx b/website/docs/segments/npm.mdx index af829418..0ad6f63e 100644 --- a/website/docs/segments/npm.mdx +++ b/website/docs/segments/npm.mdx @@ -10,26 +10,31 @@ Display the currently active [npm][npm-docs] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `fetch_version` | `boolean` | fetch the NPM version - defaults to `true` | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `package.json` or `package-lock.json` file are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `fetch_version` | `boolean` | fetch the NPM version - defaults to `true` | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `package.json` or `package-lock.json` file are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/nx.mdx b/website/docs/segments/nx.mdx index b8aacd28..e9eb3cc9 100644 --- a/website/docs/segments/nx.mdx +++ b/website/docs/segments/nx.mdx @@ -10,25 +10,30 @@ Display the currently active [Nx][nx-docs] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `ng` | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `workspace.json` or `nx.json` file is present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the active version or not; useful if all you need is an icon indicating `ng` | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `workspace.json` or `nx.json` file is present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/ocaml.mdx b/website/docs/segments/ocaml.mdx index fa6c9aca..da15bb58 100644 --- a/website/docs/segments/ocaml.mdx +++ b/website/docs/segments/ocaml.mdx @@ -10,24 +10,29 @@ Display the currently active OCaml version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the ocaml version (`ocaml -version`) - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the ocaml version (`ocaml -version`) - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/perl.mdx b/website/docs/segments/perl.mdx index 31a3c83d..79f92467 100644 --- a/website/docs/segments/perl.mdx +++ b/website/docs/segments/perl.mdx @@ -10,25 +10,30 @@ Display the currently active perl version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the perl version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the perl command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `.perl-version`
    • `*.pl`
    • `*.p`
    • `*.t`
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the perl version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the perl command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `.perl-version`
    • `*.pl`
    • `*.p`
    • `*.t`
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/php.mdx b/website/docs/segments/php.mdx index c8a7bdd5..022cf719 100644 --- a/website/docs/segments/php.mdx +++ b/website/docs/segments/php.mdx @@ -10,26 +10,31 @@ Display the currently active php version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the php version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `*.php`
    • `composer.json`
    • `composer.lock`
    • `.php-version`
    • `blade.php`
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the php version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `*.php`
    • `composer.json`
    • `composer.lock`
    • `.php-version`
    • `blade.php`
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/python.mdx b/website/docs/segments/python.mdx index 9ea5d000..dbda19e0 100644 --- a/website/docs/segments/python.mdx +++ b/website/docs/segments/python.mdx @@ -13,28 +13,33 @@ If your virtual environment is a directory named `venv` or `.venv`, the virtual ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_virtual_env` | `boolean` | fetch the name of the virtualenv or not - defaults to `true` | -| `display_default` | `boolean` | show the name of the virtualenv when it's default (`system`, `base`) or not - defaults to `true` | -| `fetch_version` | `boolean` | fetch the python version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present:
    • `*.py`
    • `*.ipynb`
    • `pyproject.toml`
    • `venv.bak`
    • `venv`
    • `.venv`
  • `environment`: the segment is only displayed when a virtual env is present (**default**)
  • `context`: the segment is only displayed when either `environment` or `files` is active
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_virtual_env` | `boolean` | fetch the name of the virtualenv or not - defaults to `true` | +| `display_default` | `boolean` | show the name of the virtualenv when it's default (`system`, `base`) or not - defaults to `true` | +| `fetch_version` | `boolean` | fetch the python version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present:
    • `*.py`
    • `*.ipynb`
    • `pyproject.toml`
    • `venv.bak`
    • `venv`
    • `.venv`
  • `environment`: the segment is only displayed when a virtual env is present (**default**)
  • `context`: the segment is only displayed when either `environment` or `files` is active
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/quasar.mdx b/website/docs/segments/quasar.mdx index c107f1f3..7ec90320 100644 --- a/website/docs/segments/quasar.mdx +++ b/website/docs/segments/quasar.mdx @@ -26,13 +26,16 @@ import Config from "@site/src/components/Config.js"; ## Properties -| Name | Type | Description | -| ---------------------- | --------- | --------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `fetch_version` | `boolean` | fetch the NPM version - defaults to `true` | -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | -| `fetch_dependencies` | `boolean` | fetch the version number of the `vite` and `@quasar/app-vite` dependencies if present - defaults to `false` | +| Name | Type | Description | +| ---------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `fetch_version` | `boolean` | fetch the NPM version - defaults to `true` | +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `fetch_dependencies` | `boolean` | fetch the version number of the `vite` and `@quasar/app-vite` dependencies if present - defaults to `false` | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/r.mdx b/website/docs/segments/r.mdx index 9be88450..d818bb94 100644 --- a/website/docs/segments/r.mdx +++ b/website/docs/segments/r.mdx @@ -10,26 +10,31 @@ Display the currently active [R][r-homepage] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the R version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `*.R`
    • `*.Rmd`
    • `*.Rsx`
    • `*.Rda`
    • `*.Rd`
    • `*.Rproj`
    • `.Rproj.user`
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the R version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when one of the following files is present (**default**):
    • `*.R`
    • `*.Rmd`
    • `*.Rsx`
    • `*.Rda`
    • `*.Rd`
    • `*.Rproj`
    • `.Rproj.user`
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/ruby.mdx b/website/docs/segments/ruby.mdx index f9c95503..13aeb60a 100644 --- a/website/docs/segments/ruby.mdx +++ b/website/docs/segments/ruby.mdx @@ -10,25 +10,30 @@ Display the currently active ruby version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the ruby version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rb`, `Gemfile` or `Rakefile` files are present (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the ruby version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rb`, `Gemfile` or `Rakefile` files are present (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/rust.mdx b/website/docs/segments/rust.mdx index 83b8e563..0a6131c6 100644 --- a/website/docs/segments/rust.mdx +++ b/website/docs/segments/rust.mdx @@ -10,25 +10,30 @@ Display the currently active rust version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the rust version (`rustc --version`) - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the rust version (`rustc --version`) - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.rs`, `Cargo.toml` or `Cargo.lock` files are present (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/swift.mdx b/website/docs/segments/swift.mdx index b09158c0..00fd5b0d 100644 --- a/website/docs/segments/swift.mdx +++ b/website/docs/segments/swift.mdx @@ -10,26 +10,31 @@ Display the currently active [Swift][swift] version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the swift version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.swift` or `*.SWIFT` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the swift version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.swift` or `*.SWIFT` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/ui5tooling.mdx b/website/docs/segments/ui5tooling.mdx index 1d29b5c0..387d27ad 100644 --- a/website/docs/segments/ui5tooling.mdx +++ b/website/docs/segments/ui5tooling.mdx @@ -11,26 +11,31 @@ see [the documentation][ui5-version-help]). ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the UI5 tooling version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*ui5*.y(a)ml` file is present in the current folder
  • `context`: the segment is only displayed when `*ui5*.y(a)ml` file is present in the current folder or it has been found in the parent folders (check up to 4 levels) (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the UI5 tooling version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the java command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*ui5*.y(a)ml` file is present in the current folder
  • `context`: the segment is only displayed when `*ui5*.y(a)ml` file is present in the current folder or it has been found in the parent folders (check up to 4 levels) (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/vala.mdx b/website/docs/segments/vala.mdx index df5334b4..8b2d7e71 100644 --- a/website/docs/segments/vala.mdx +++ b/website/docs/segments/vala.mdx @@ -10,26 +10,31 @@ Display the currently active vala version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | fetch the flutter version - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.vala` files are present (**default**)
| -| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| Name | Type | Description | +| ---------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | fetch the flutter version - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when `*.vala` files are present (**default**)
| +| `version_url_template` | `string` | a go [text/template][go-text-template] [template][templates] that creates the URL of the version info / release notes | +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([info][templates]) diff --git a/website/docs/segments/xmake.mdx b/website/docs/segments/xmake.mdx index 930a8f58..47f83e47 100644 --- a/website/docs/segments/xmake.mdx +++ b/website/docs/segments/xmake.mdx @@ -10,25 +10,30 @@ Display the currently active xmake version. ## Sample Configuration -import Config from '@site/src/components/Config.js'; +import Config from "@site/src/components/Config.js"; - + ## Properties -| Name | Type | Description | -| ---------------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | -| `fetch_version` | `boolean` | display the xmake version (`xmake --version`) - defaults to `true` | -| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | -| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `xmake.lua` file is present (**default**)
| +| Name | Type | Description | +| ---------------------- | ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `home_enabled` | `boolean` | display the segment in the HOME folder or not - defaults to `false` | +| `fetch_version` | `boolean` | display the xmake version (`xmake --version`) - defaults to `true` | +| `missing_command_text` | `string` | text to display when the command is missing - defaults to empty | +| `display_mode` | `string` |
  • `always`: the segment is always displayed
  • `files`: the segment is only displayed when a `xmake.lua` file is present (**default**)
| +| `extensions` | `[]string` | allows to override the default list of file extensions to validate | +| `folders` | `[]string` | allows to override the list of folders names to validate | +| `cache_version` | `boolean` | cache the executable's version or not - defaults to `false` | ## Template ([into][templates])