plugin

package module
v0.0.0-...-017022c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2019 License: MPL-2.0 Imports: 0 Imported by: 0

README

Nushell Plugin in GoLang

This is a base library for generating a nushell plugin in Golang. As nushell is under development, it's likely that not all features are implemented here! Please open an issue if you need help.

Filter Plugin

I've done a basic filter example to calculate the length of a string, and the usage is summarized as follows:

package main
 
import nu "github.com/vsoch/nu-plugin/pkg/plugin"


// filter will read stream from nushell and print a response
func filter(plugin *nu.FilterPlugin, params interface{}) {

	// can also be getIntPrimitive
	value := plugin.Func.GetStringPrimitive(params)

	// Put your logic here! In this case, we want a length
	intLength := len(value)

	// You must also return the tag with your response
	tag := plugin.Func.GetTag(params)

	// This can also be printStringResponse
	plugin.Func.PrintIntResponse(intLength, tag)

}


func main() {

	name := "len"
	usage := "Return the length of a string"
	plugin := nu.NewFilterPlugin(name, usage)

	// Run the filter function
	plugin.Run(filter)
}

For more details, see the full example.

Sink Plugin

We have two examples for Sink plugins:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Config

func Config() string

Types

This section is empty.

Directories

Path Synopsis
examples
len
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL