diff options
Diffstat (limited to 'generate.sh')
-rwxr-xr-x | generate.sh | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/generate.sh b/generate.sh index 7c431ec..50a0e3a 100755 --- a/generate.sh +++ b/generate.sh @@ -1,16 +1,5 @@ #!/bin/sh -if [ $# != 1 ]; then - echo >&2 "usage: $(basename "$0") <filename.wav>" - exit 1 -fi - -filename="$1" -name="$(basename -s .wav "${filename}")" -root="$(dirname "$0")" - -mkdir -p "${root}/cmd/${name}" -cp "${filename}" "${root}/cmd/${name}/${name}.wav" -gofmt > "${root}/cmd/${name}/${name}.go" << EOF +gofmt > main.go << EOF package main import ( @@ -19,14 +8,14 @@ import ( "os/exec" ) -//go:generate ../../generate.sh ${name}.wav +//go:generate generate.sh func main() { - f, err := ioutil.TempFile(os.TempDir(), "${name}") + f, err := ioutil.TempFile(os.TempDir(), os.Args[0]) if err != nil { panic(err) } defer os.Remove(f.Name()) - if _, err := f.Write(${name}); err != nil { + if _, err := f.Write(sound); err != nil { panic(err) } cmd := exec.Command("afplay", f.Name()) @@ -37,7 +26,7 @@ func main() { } } -var ${name} = []byte{ - $(xxd -i < "${filename}" | sed 's/\([^,]\)$/\1,/') +var sound = []byte{ + $(xxd -i < sound.wav | sed 's/\([^,]\)$/\1,/') } EOF
\ No newline at end of file |