added simple command to emit byte patterns to stdout
This commit is contained in:
parent
e21b3e2452
commit
437c2234b5
36
cmd/trash/main.go
Normal file
36
cmd/trash/main.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"mcquay.me/trash"
|
||||||
|
)
|
||||||
|
|
||||||
|
var algo = flag.String("a", "caca", "algorithm to use")
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
flag.Parse()
|
||||||
|
var r io.Reader
|
||||||
|
switch *algo {
|
||||||
|
case "low", "00", "0", "nil", "null", "zeros":
|
||||||
|
r = trash.Zeros
|
||||||
|
case "ones", "ff", "hi":
|
||||||
|
r = trash.Fs
|
||||||
|
case "trash", "caca":
|
||||||
|
r = trash.Reader
|
||||||
|
case "hilo", "aa", "a":
|
||||||
|
r = trash.HiLo
|
||||||
|
case "lohi", "55", "5":
|
||||||
|
r = trash.LoHi
|
||||||
|
default:
|
||||||
|
fmt.Fprintf(os.Stderr, "unsupported algorithm: %v\ntry one of 'low', 'high', 'hilo', 'lohi', 'trash'\n", *algo)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
if _, err := io.Copy(os.Stdout, r); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "problem copying to stdout: %v", err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user