mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-26 11:34:04 -08:00
feat: support crystal language
This commit is contained in:
parent
a0ae4a7e4b
commit
8f473df62f
33
docs/docs/segment-crystal.md
Normal file
33
docs/docs/segment-crystal.md
Normal file
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
id: crystal
|
||||
title: Crystal
|
||||
sidebar_label: Crystal
|
||||
---
|
||||
|
||||
## What
|
||||
|
||||
Display the currently active crystal version.
|
||||
|
||||
## Sample Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "crystal",
|
||||
"style": "powerline",
|
||||
"powerline_symbol": "\uE0B0",
|
||||
"foreground": "#ffffff",
|
||||
"background": "#4063D8",
|
||||
"properties": {
|
||||
"prefix": " \uE370 "
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 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 `*.cr` or `shard.yml` files are present (default)
|
|
@ -32,6 +32,7 @@ module.exports = {
|
|||
"azfunc",
|
||||
"battery",
|
||||
"command",
|
||||
"crystal",
|
||||
"dotnet",
|
||||
"environment",
|
||||
"executiontime",
|
||||
|
|
|
@ -111,6 +111,8 @@ const (
|
|||
PoshGit SegmentType = "poshgit"
|
||||
// AZFunc writes current AZ func version
|
||||
AZFunc SegmentType = "azfunc"
|
||||
// Crystal writes the active crystal version
|
||||
Crystal SegmentType = "crystal"
|
||||
)
|
||||
|
||||
func (segment *Segment) string() string {
|
||||
|
@ -236,6 +238,7 @@ func (segment *Segment) mapSegmentWithWriter(env environmentInfo) error {
|
|||
Java: &java{},
|
||||
PoshGit: &poshgit{},
|
||||
AZFunc: &azfunc{},
|
||||
Crystal: &crystal{},
|
||||
}
|
||||
if writer, ok := functions[segment.Type]; ok {
|
||||
props := &properties{
|
||||
|
|
29
src/segment_crystal.go
Normal file
29
src/segment_crystal.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
type crystal struct {
|
||||
language *language
|
||||
}
|
||||
|
||||
func (c *crystal) string() string {
|
||||
return c.language.string()
|
||||
}
|
||||
|
||||
func (c *crystal) init(props *properties, env environmentInfo) {
|
||||
c.language = &language{
|
||||
env: env,
|
||||
props: props,
|
||||
extensions: []string{"*.cr", "shard.yml"},
|
||||
commands: []*cmd{
|
||||
{
|
||||
executable: "crystal",
|
||||
args: []string{"--version"},
|
||||
regex: `Crystal (?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
|
||||
},
|
||||
},
|
||||
versionURLTemplate: "[%s](https://github.com/crystal-lang/crystal/releases/tag/%s.%s.%s)",
|
||||
}
|
||||
}
|
||||
|
||||
func (c *crystal) enabled() bool {
|
||||
return c.language.enabled()
|
||||
}
|
|
@ -152,7 +152,8 @@
|
|||
"aws",
|
||||
"java",
|
||||
"poshgit",
|
||||
"azfunc"
|
||||
"azfunc",
|
||||
"crystal"
|
||||
]
|
||||
},
|
||||
"style": {
|
||||
|
@ -690,6 +691,32 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"type": { "const": "crystal" }
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"title": "Crystal Segment",
|
||||
"description": "https://ohmyposh.dev/docs/crystal",
|
||||
"properties": {
|
||||
"properties": {
|
||||
"properties": {
|
||||
"display_version": {
|
||||
"$ref": "#/definitions/display_version"
|
||||
},
|
||||
"display_mode": {
|
||||
"$ref": "#/definitions/display_mode"
|
||||
},
|
||||
"missing_command_text": {
|
||||
"$ref": "#/definitions/missing_command_text"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
|
|
Loading…
Reference in a new issue