Hi,
Purposebuilds pipes to transform a data stream.
It comes with a generator to avoid you some copy paste,
and provide a standard bytes stream to get started with []byte.
ExampleFollowing example reads a source of []byte, os.Stdin,
as a list of versions, one per line,
manipulates and transforms the chunks
until the data is written on the sink, os.Stdout.
//Package cmd implement a cli tool to manipulate Versions.
package main
import (
"os"
"github.com/mh-cbon/semver/cmd/stream"
)
func main() {
src := os.Stdin
pipeSrc := stream.NewByteReader(src)
pipe := pipeSrc.
Pipe(stream.NewBytesSplitter(' ', '\n')).
Pipe(&stream.BytesTrimer{}).
Pipe(&stream.VersionFromByte{SkipInvalid: true}).
Pipe(&stream.VersionSorter{Asc: true}).
Pipe(&stream.LastVersionOnly{}).
Pipe(&stream.VersionToByte{}).
Pipe(stream.NewBytesPrefixer("- ", "\n"))
pipe.Sink(stream.NewByteSink(dest))
if err := pipeSrc.Consume(); err != nil {
panic(err)
}
os.Exit(0)
}
URLhttps://mh-cbon.github.io/plumber/https://github.com/mh-cbon/plumberWIP?yeah, let s write tests ect when its needed.
HTH