sm
/
trash
1
0
Fork 0

added simple command to emit byte patterns to stdout

This commit is contained in:
Stephen McQuay 2016-06-02 23:16:22 -07:00
parent e21b3e2452
commit 437c2234b5
No known key found for this signature in database
GPG Key ID: 1ABF428F71BAFC3D
1 changed files with 36 additions and 0 deletions

36
cmd/trash/main.go Normal file
View 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)
}
}