pentaradio-tools/main.go

53 lines
1.2 KiB
Go
Raw Normal View History

2022-04-17 00:27:08 +02:00
/*******************************************************************************
* Copyright 2022 Stefan Majewsky <majewsky@gmx.net>
* SPDX-License-Identifier: GPL-3.0-only
* Refer to the file "LICENSE" for details.
*******************************************************************************/
package main
2022-04-17 01:57:02 +02:00
import (
"fmt"
"os"
2022-04-21 21:27:41 +02:00
"path/filepath"
2022-04-17 01:57:02 +02:00
)
2022-04-17 00:27:08 +02:00
func main() {
2022-04-21 21:27:41 +02:00
if len(os.Args) != 2 {
usage(1)
}
switch os.Args[1] {
case "upload":
Upload(Scan())
case "generate":
Generate(Scan())
case "help", "--help":
usage(0)
}
2022-04-17 01:57:02 +02:00
}
func must(err error) {
if err != nil {
fail(err.Error())
}
}
func fail(msg string, args ...interface{}) {
if len(args) > 0 {
msg = fmt.Sprintf(msg, args...)
}
fmt.Fprintln(os.Stderr, "ERROR: ", msg)
os.Exit(1)
2022-04-17 00:27:08 +02:00
}
2022-04-21 21:27:41 +02:00
func usage(exitCode int) {
fmt.Fprintf(os.Stderr,
"Usage:\n\n"+
" %[1]s upload - Upload all relevant files for one episode to <sftp://ftp.c3d2.de>.\n"+
" %[1]s generate - Generate the c3d2-web news entry XML file for one episode.\n\n"+
"All relevant files (audios, chapter marks file, shownotes Markdown file) must be in the working directory.\n",
filepath.Base(os.Args[0]),
)
os.Exit(exitCode)
}