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 ¶
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 ¶
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 ¶
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.