flags and error messages
This commit is contained in:
parent
e34f699baa
commit
1191484efa
1 changed files with 7 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.lattuga.net/boyska/direttoforo.git/liquidsoap"
|
"git.lattuga.net/boyska/direttoforo.git/liquidsoap"
|
||||||
"os"
|
"os"
|
||||||
|
@ -17,12 +18,15 @@ func outUI(output chan liquidsoap.Output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
liqfile := flag.String("liq", "foo.liq", "Path to liquidsoap script to run")
|
||||||
|
flag.Parse()
|
||||||
|
|
||||||
killLs := make(chan struct{}) // when it is closed, liquidsoap will die
|
killLs := make(chan struct{}) // when it is closed, liquidsoap will die
|
||||||
killed := make(chan os.Signal, 1)
|
killed := make(chan os.Signal, 1)
|
||||||
signal.Notify(killed, os.Interrupt) // ctrl-c
|
signal.Notify(killed, os.Interrupt) // ctrl-c
|
||||||
output, exit, err := liquidsoap.RunLiquidsoap("foo.liq", killLs)
|
output, exit, err := liquidsoap.RunLiquidsoap(*liqfile, killLs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, "Error spawning liquidsoap", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +55,7 @@ func main() {
|
||||||
select {
|
select {
|
||||||
case how := <-exit: // liquidsoap exits
|
case how := <-exit: // liquidsoap exits
|
||||||
if !how.Success() {
|
if !how.Success() {
|
||||||
fmt.Fprintln(os.Stderr, how.Err)
|
fmt.Fprintln(os.Stderr, "liquidsoap terminated,", how.Err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
Loading…
Reference in a new issue