pipe

package
v0.83.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pipe provides a simple API to read and retrieve values from stdin to use in Cobra commands. Public API consists of GetInput, which reads stdin, Exists, which checks for value existence, and Get for retrieving existing values.

Index

Constants

This section is empty.

Variables

View Source
var GetInput = getPipeInputFactory(stdinPipeReader{input: os.Stdin}, utils.StdinExists)

GetInput takes a slice of gjson selectors (https://github.com/tidwall/gjson/blob/master/SYNTAX.md) as an argument. When ran once at the top the init function, GetInput stores those desired json values from stdin. The existence of and values of those stdin json keys can then be retrieved using the public Exists and Get methods, respectively.

Functions

func Exists

func Exists(inputKey string) bool

Exists is meant to be used in the init function, after GetInput is called, to determine if a required Cobra flag needs to be declared. If the inputKey exists in the Pipe module, then you can skip the required flag declaration and used the piped in values instead.

func Get

func Get(inputKey string) ([]string, bool)

Get is the only API provided to retrieve values from stdin json. Get is designed to be used in the cobra command itself, when any required value fed into stdin is needed. If stdin is empty or the value specified does not exist, Get will return nil for the value and false for the ok check.

Types

This section is empty.

Jump to

Keyboard shortcuts

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