From f495a7093ac9ef15d2d904d86c9f17e1c075904a Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Sat, 4 Dec 2021 10:32:50 +0100 Subject: [PATCH] feat(language): add error text to template properties --- docs/docs/segment-angular.md | 11 ++++++----- docs/docs/segment-azfunc.md | 11 ++++++----- docs/docs/segment-crystal.md | 11 ++++++----- docs/docs/segment-dart.md | 11 ++++++----- docs/docs/segment-dotnet.md | 11 ++++++----- docs/docs/segment-golang.md | 11 ++++++----- docs/docs/segment-java.md | 11 ++++++----- docs/docs/segment-julia.md | 11 ++++++----- docs/docs/segment-node.md | 11 ++++++----- docs/docs/segment-php.md | 11 ++++++----- docs/docs/segment-python.md | 11 ++++++----- docs/docs/segment-ruby.md | 11 ++++++----- docs/docs/segment-rust.md | 11 ++++++----- src/segment_language.go | 2 ++ 14 files changed, 80 insertions(+), 65 deletions(-) diff --git a/docs/docs/segment-angular.md b/docs/docs/segment-angular.md index c3072398..352d9580 100644 --- a/docs/docs/segment-angular.md +++ b/docs/docs/segment-angular.md @@ -35,11 +35,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-azfunc.md b/docs/docs/segment-azfunc.md index 984c0fb4..2abc25c8 100644 --- a/docs/docs/segment-azfunc.md +++ b/docs/docs/segment-azfunc.md @@ -39,11 +39,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-crystal.md b/docs/docs/segment-crystal.md index 8f995bc8..e21733cc 100644 --- a/docs/docs/segment-crystal.md +++ b/docs/docs/segment-crystal.md @@ -38,11 +38,12 @@ Display the currently active crystal version. ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-dart.md b/docs/docs/segment-dart.md index 9eb1d0e7..631f029a 100644 --- a/docs/docs/segment-dart.md +++ b/docs/docs/segment-dart.md @@ -39,11 +39,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-dotnet.md b/docs/docs/segment-dotnet.md index 83bb0c20..f46cb7c6 100644 --- a/docs/docs/segment-dotnet.md +++ b/docs/docs/segment-dotnet.md @@ -44,11 +44,12 @@ with [sprig][sprig] utilizing the properties below. Defaults does nothing(backwa ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-golang.md b/docs/docs/segment-golang.md index 7790269c..1aacf4b3 100644 --- a/docs/docs/segment-golang.md +++ b/docs/docs/segment-golang.md @@ -38,8 +38,9 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors diff --git a/docs/docs/segment-java.md b/docs/docs/segment-java.md index c13c3e0c..cb358d83 100644 --- a/docs/docs/segment-java.md +++ b/docs/docs/segment-java.md @@ -51,8 +51,9 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors diff --git a/docs/docs/segment-julia.md b/docs/docs/segment-julia.md index 3a4a0ecc..74d705ac 100644 --- a/docs/docs/segment-julia.md +++ b/docs/docs/segment-julia.md @@ -38,11 +38,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-node.md b/docs/docs/segment-node.md index ced7d23e..be998cbf 100644 --- a/docs/docs/segment-node.md +++ b/docs/docs/segment-node.md @@ -46,11 +46,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-php.md b/docs/docs/segment-php.md index 47b8ea48..47b09fbc 100644 --- a/docs/docs/segment-php.md +++ b/docs/docs/segment-php.md @@ -40,11 +40,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-python.md b/docs/docs/segment-python.md index 7c4eaa4d..be56175c 100644 --- a/docs/docs/segment-python.md +++ b/docs/docs/segment-python.md @@ -46,11 +46,12 @@ properties below. Defaults to `{{ .Full }}` - `.Venv`: `string` - the virtual environment name (if present) - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-ruby.md b/docs/docs/segment-ruby.md index 5d812f68..c15e2643 100644 --- a/docs/docs/segment-ruby.md +++ b/docs/docs/segment-ruby.md @@ -38,11 +38,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/docs/docs/segment-rust.md b/docs/docs/segment-rust.md index c0f2a431..40a1ce56 100644 --- a/docs/docs/segment-rust.md +++ b/docs/docs/segment-rust.md @@ -38,11 +38,12 @@ properties below. Defaults to `{{ .Full }}` ## Template Properties - `.Full`: `string` - the full version -- `.Major`: `string` - is the major version -- `.Minor`: `string` - is the minor version -- `.Patch`: `string` - is the patch version -- `.Prerelease`: `string` - is the prerelease version -- `.BuildMetadata`: `string` - is the build metadata +- `.Major`: `string` - major number +- `.Minor`: `string` - minor number +- `.Patch`: `string` - patch number +- `.Prerelease`: `string` - prerelease info text +- `.BuildMetadata`: `string` - build metadata +- `.Error`: `string` - when fetching the version string errors [go-text-template]: https://golang.org/pkg/text/template/ [sprig]: https://masterminds.github.io/sprig/ diff --git a/src/segment_language.go b/src/segment_language.go index 2cfffa89..26d36d5b 100644 --- a/src/segment_language.go +++ b/src/segment_language.go @@ -58,6 +58,7 @@ type language struct { displayMode string version + Error string } const ( @@ -89,6 +90,7 @@ func (l *language) string() string { } err := l.setVersion() + l.Error = err.Error() displayError := l.props.getBool(DisplayError, true) if err != nil && displayError { return err.Error()