feat: azure functions segment

This commit is contained in:
Jan De Dobbeleer 2021-04-02 19:36:50 +02:00 committed by Jan De Dobbeleer
parent 64aa66eebc
commit 8afadc0bcd
4 changed files with 67 additions and 0 deletions

View 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)

View file

@ -11,6 +11,7 @@ module.exports = {
items: [
"aws",
"az",
"azfunc",
"battery",
"command",
"dotnet",

View file

@ -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{

View 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()
}