Repository: JanDeDobbeleer/oh-my-posh
Pull request #678 (2021-04-22 18:19:20)

feat: display message on az update needed
### Prerequisites

- [ ] I have read and understand the `CONTRIBUTING` guide
- [ ] The commit message follows the [conventional commits][cc] guidelines
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)

### Description

[Description of the change]

[cc]: https://www.conventionalcommits.org/en/v1.0.0/#summary



Patch:
diff --git a/src/segment_az.go b/src/segment_az.go
index a51f3846..4b2afb5e 100644
--- a/src/segment_az.go
+++ b/src/segment_az.go
@@ -19,6 +19,11 @@ const (
 	DisplaySubscriptionID Property = "display_id"
 	// DisplaySubscriptionName hides or shows the subscription display name
 	DisplaySubscriptionName Property = "display_name"
+
+	updateConsentNeeded = "Do you want to continue?"
+	updateMessage       = "AZ CLI: Update needed!"
+	updateForeground    = "#ffffff"
+	updateBackground    = "#ff5349"
 )
 
 func (a *az) string() string {
@@ -68,6 +73,12 @@ func (a *az) getFromAzCli() (string, string, bool) {
 		return "", "", false
 	}
 
+	if strings.Contains(output, updateConsentNeeded) {
+		a.props.foreground = updateForeground
+		a.props.background = updateBackground
+		return updateMessage, "", true
+	}
+
 	splittedOutput := strings.Split(output, "\n")
 	if len(splittedOutput) < 2 {
 		return "", "", false


Test patch:
diff --git a/src/segment_az_test.go b/src/segment_az_test.go
index 0df232aa..c9656744 100644
--- a/src/segment_az_test.go
+++ b/src/segment_az_test.go
@@ -21,7 +21,8 @@ func TestAzSegment(t *testing.T) {
 		DisplayID       bool
 		DisplayName     bool
 	}{
-		{Case: "envvars present",
+		{
+			Case:            "envvars present",
 			ExpectedEnabled: true,
 			ExpectedString:  "foo$bar",
 			EnvSubName:      "foo",
@@ -29,78 +30,89 @@ func TestAzSegment(t *testing.T) {
 			CliExists:       false,
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     true},
-		{Case: "envvar name present",
+			DisplayName:     true,
+		},
+		{
+			Case:            "envvar name present",
 			ExpectedEnabled: true,
 			ExpectedString:  "foo$",
 			EnvSubName:      "foo",
-			EnvSubID:        "",
 			CliExists:       false,
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     true},
-		{Case: "envvar id present",
+			DisplayName:     true,
+		},
+		{
+			Case:            "envvar id present",
 			ExpectedEnabled: true,
 			ExpectedString:  "$bar",
-			EnvSubName:      "",
 			EnvSubID:        "bar",
 			CliExists:       false,
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     true},
-		{Case: "cli not found",
+			DisplayName:     true,
+		},
+		{
+			Case:            "cli not found",
 			ExpectedEnabled: false,
 			ExpectedString:  "$",
-			EnvSubName:      "",
-			EnvSubID:        "",
 			CliExists:       false,
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     true},
-		{Case: "cli contains data",
+			DisplayName:     true,
+		},
+		{
+			Case:            "cli contains data",
 			ExpectedEnabled: true,
 			ExpectedString:  "foo$bar",
-			EnvSubName:      "",
-			EnvSubID:        "",
 			CliExists:       true,
 			CliSubName:      "foo",
 			CliSubID:        "bar",
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     true},
-		{Case: "print only name",
+			DisplayName:     true,
+		},
+		{
+			Case:            "print only name",
 			ExpectedEnabled: true,
 			ExpectedString:  "foo",
-			EnvSubName:      "",
-			EnvSubID:        "",
 			CliExists:       true,
 			CliSubName:      "foo",
 			CliSubID:        "bar",
 			InfoSeparator:   "$",
 			DisplayID:       false,
-			DisplayName:     true},
-		{Case: "print only id",
+			DisplayName:     true,
+		},
+		{
+			Case:            "print only id",
 			ExpectedEnabled: true,
 			ExpectedString:  "bar",
-			EnvSubName:      "",
-			EnvSubID:        "",
 			CliExists:       true,
 			CliSubName:      "foo",
 			CliSubID:        "bar",
 			InfoSeparator:   "$",
 			DisplayID:       true,
-			DisplayName:     false},
-		{Case: "print none",
+			DisplayName:     false,
+		},
+		{
+			Case:            "print none",
 			ExpectedEnabled: false,
-			ExpectedString:  "",
-			EnvSubName:      "",
-			EnvSubID:        "",
 			CliExists:       true,
 			CliSubName:      "foo",
 			CliSubID:        "bar",
 			InfoSeparator:   "$",
 			DisplayID:       false,
-			DisplayName:     false},
+			DisplayName:     false,
+		},
+		{
+			Case:            "update needed",
+			ExpectedEnabled: true,
+			ExpectedString:  updateMessage,
+			CliExists:       true,
+			CliSubName:      "Do you want to continue? (Y/n): Visual Studio Enterprise",
+			DisplayID:       false,
+			DisplayName:     true,
+		},
 	}
 
 	for _, tc := range cases {