mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-10 04:54:03 -08:00
feat: azure functions segment
This commit is contained in:
parent
64aa66eebc
commit
8afadc0bcd
35
docs/docs/segment-azfunc.md
Normal file
35
docs/docs/segment-azfunc.md
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
id: azfunc
|
||||
title: Azure functions
|
||||
sidebar_label: Azure functions
|
||||
---
|
||||
|
||||
## What
|
||||
|
||||
Display the currently active Azure functions CLI version.
|
||||
|
||||
## Sample Configuration
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "azfunc",
|
||||
"style": "powerline",
|
||||
"powerline_symbol": "",
|
||||
"foreground": "#ffffff",
|
||||
"background": "#FEAC19",
|
||||
"properties": {
|
||||
"prefix": " \uf0e7 ",
|
||||
"display_version": true,
|
||||
"display_mode": "files"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
- display_version: `boolean` - display the Azure functions CLI 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 a `host.json` or `local.settings.json` files is present (default)
|
|
@ -11,6 +11,7 @@ module.exports = {
|
|||
items: [
|
||||
"aws",
|
||||
"az",
|
||||
"azfunc",
|
||||
"battery",
|
||||
"command",
|
||||
"dotnet",
|
||||
|
|
|
@ -98,6 +98,8 @@ const (
|
|||
Java SegmentType = "java"
|
||||
// PoshGit writes the posh git prompt
|
||||
PoshGit SegmentType = "poshgit"
|
||||
// AZFunc writes current AZ func version
|
||||
AZFunc SegmentType = "azfunc"
|
||||
)
|
||||
|
||||
func (segment *Segment) string() string {
|
||||
|
@ -222,6 +224,7 @@ func (segment *Segment) mapSegmentWithWriter(env environmentInfo) error {
|
|||
Aws: &aws{},
|
||||
Java: &java{},
|
||||
PoshGit: &poshgit{},
|
||||
AZFunc: &azfunc{},
|
||||
}
|
||||
if writer, ok := functions[segment.Type]; ok {
|
||||
props := &properties{
|
||||
|
|
28
src/segment_az_functions.go
Normal file
28
src/segment_az_functions.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
type azfunc struct {
|
||||
language *language
|
||||
}
|
||||
|
||||
func (az *azfunc) string() string {
|
||||
return az.language.string()
|
||||
}
|
||||
|
||||
func (az *azfunc) init(props *properties, env environmentInfo) {
|
||||
az.language = &language{
|
||||
env: env,
|
||||
props: props,
|
||||
extensions: []string{"host.json", "local.settings.json"},
|
||||
commands: []*cmd{
|
||||
{
|
||||
executable: "func",
|
||||
args: []string{"--version"},
|
||||
regex: `(?P<version>.+)`,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (az *azfunc) enabled() bool {
|
||||
return az.language.enabled()
|
||||
}
|
Loading…
Reference in a new issue