forked from JanDeDobbeleer/oh-my-posh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d96cb79
commit 4030c32
Showing
7 changed files
with
127 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
id: dart | ||
title: Dart | ||
sidebar_label: Dart | ||
--- | ||
|
||
## What | ||
|
||
Display the currently active dart version. | ||
|
||
## Sample Configuration | ||
|
||
```json | ||
{ | ||
"type": "dart", | ||
"style": "powerline", | ||
"powerline_symbol": "\uE0B0", | ||
"foreground": "#ffffff", | ||
"background": "#06A4CE", | ||
"properties": { | ||
"prefix": " \uE798 " | ||
} | ||
} | ||
``` | ||
|
||
## Properties | ||
|
||
- display_version: `boolean` - display the julia version - defaults to `true` | ||
- display_error: `boolean` - show the error context when failing to retrieve the version information - defaults to `true` | ||
- missing_command_text: `string` - text to display when the command is missing - defaults to empty | ||
- display_mode: `string` - determines when the segment is displayed | ||
- `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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
type dart struct { | ||
language *language | ||
} | ||
|
||
func (d *dart) string() string { | ||
return d.language.string() | ||
} | ||
|
||
func (d *dart) init(props *properties, env environmentInfo) { | ||
d.language = &language{ | ||
env: env, | ||
props: props, | ||
extensions: []string{"*.dart", "pubspec.yaml", "pubspec.yml", "pubspec.lock", ".dart_tool"}, | ||
commands: []*cmd{ | ||
{ | ||
executable: "dart", | ||
args: []string{"--version"}, | ||
regex: `Dart SDK version: (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`, | ||
}, | ||
}, | ||
versionURLTemplate: "[%s](https://dart.dev/guides/language/evolution#dart-%s%s)", | ||
} | ||
} | ||
|
||
func (d *dart) enabled() bool { | ||
return d.language.enabled() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestDart(t *testing.T) { | ||
cases := []struct { | ||
Case string | ||
ExpectedString string | ||
Version string | ||
}{ | ||
{Case: "Dart 2.12.4", ExpectedString: "2.12.4", Version: "Dart SDK version: 2.12.4 (stable) (Thu Apr 15 12:26:53 2021 +0200) on \"macos_x64\""}, | ||
} | ||
for _, tc := range cases { | ||
params := &mockedLanguageParams{ | ||
cmd: "dart", | ||
versionParam: "--version", | ||
versionOutput: tc.Version, | ||
extension: "*.dart", | ||
} | ||
env, props := getMockedLanguageEnv(params) | ||
d := &dart{} | ||
d.init(props, env) | ||
assert.True(t, d.enabled(), fmt.Sprintf("Failed in case: %s", tc.Case)) | ||
assert.Equal(t, tc.ExpectedString, d.string(), fmt.Sprintf("Failed in case: %s", tc.Case)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters