{"modulePath":"github.com/OctopusDeploy/cli","version":"v1.7.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package util\n\n## Functions\n\n```go\nfunc AddFlagAliasesBool(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, aliases ...string)\n```\n\n```go\nfunc AddFlagAliasesString(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, aliases ...string)\n```\n\n```go\nfunc AddFlagAliasesStringSlice(flags *pflag.FlagSet, originalFlag string, aliasMap map[string][]string, aliases ...string)\n```\n\n```go\nfunc Any[T any](items []T) bool\n```\n\n```go\nfunc ApplyFlagAliases(flags *pflag.FlagSet, aliases map[string][]string)\n```\n\n```go\nfunc Empty[T any](items []T) bool\n```\n\n```go\nfunc ExtractValuesMatchingKeys[T any](collection []T, keys []string, idSelector func(T) string, valueSelector func(T) string) []string\n```\nExtractValuesMatchingKeys returns a collection of values which matched a specified set of keys, in the exact order of keys. Given a collection of items, and a collection of keys to match within that collection This makes no sense, hopefully an example helps: - Given an array of Channels \\[\\\u003cid:C1, name:'C1Name'\u003e, \\\u003cid:C7, name:'C7Name'\u003e , \\\u003cid:C2, name:'C2Name'\u003e] - And a set of keys \\[C2, C7] - Returns the extracted values \\['C2Name', 'C7Name']\n\nNote: if something can't be found, then the extracted values collection will contain a zero value in-place\n\n```go\nfunc IsCalledFromPipe() bool\n```\n\n```go\nfunc MapCollectionWithLookups[T any, TResult any](\n\tcacheContainer *MapCollectionCacheContainer,\n\tcollection []T,\n\tkeySelector func(T) []string,\n\tmapper func(T, []string) TResult,\n\trunLookups ...func([]string) ([]string, error),\n) ([]TResult, error)\n```\nMapCollectionWithLookups does a 'map' operation over the collection, transforming each input row into an output row according to \\`mapper\\`, however it also provides the ability to collect ID's of related items as it iterates the collection, and call out to lambdas to look those values up. See the unit tests for examples which should clarify the use-cases for this.\n\n```go\nfunc ReadValuesFromPipe() []string\n```\nReadValuesFromPipe will return an array of strings from the pipe input separated by new line.\n\n```go\nfunc RemoveIndex[T any](s []T, index int) []T\n```\n\n```go\nfunc SliceContains[T comparable](slice []T, target T) bool\n```\nSliceContains returns true if it finds an item in the slice that is equal to the target\n\n```go\nfunc SliceContainsAny[T comparable](slice []T, predicate func(item T) bool) bool\n```\nSliceContainsAny returns true if it finds an item in the slice where \\`predicate\\` returns true\n\n```go\nfunc SliceDistinct[T comparable](slice []T) []T\n```\n\n```go\nfunc SliceExcept[T any](slice []T, predicate func(item T) bool) []T\n```\n\n```go\nfunc SliceFilter[T any](slice []T, predicate func(item T) bool) []T\n```\nSliceFilter takes an input collection and returns elements where \\`predicate\\` returns true Known as 'filter' in most other languages or 'Select' in C# Linq.\n\n```go\nfunc SliceTransform[T any, TResult any](slice []T, transform func(item T) TResult) []TResult\n```\nSliceTransform takes an input collection, applies the transform function to each row, and returns the output. Known as 'map' in most other languages or 'Select' in C# Linq.\n\n## Types\n\n```go\ntype MapCollectionCacheContainer struct {\n\tCaches []map[string]string\n}\n```\n\n","path":"github.com/OctopusDeploy/cli/pkg/util","name":"util","synopsis":"","isRedistributable":true}
