-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (44 loc) · 989 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"os"
"strings"
)
type flagType string
const (
FLAGTYPETEXT flagType = "text"
FLAGTYPEJSON = "json"
)
var (
paramType flagType
prefix *string
)
func init() {
flag.StringVar((*string)(¶mType), "type", "text", "The type of the input")
prefix = flag.String("prefix", "Schm", "The characters that get replaced with until the fist vowel")
}
func main() {
flag.Parse()
args := flag.Args()
if len(args) == 0 {
os.Exit(0)
}
switch paramType {
case FLAGTYPETEXT:
fmt.Print(translateText(strings.Join(args, " ")))
case FLAGTYPEJSON:
fmt.Printf("json file mode: %s\n", args[0])
err := parseJson(args[0])
if err != nil {
fmt.Printf("Failed to parse json file '%s': %v", args[0], err)
os.Exit(-1)
}
if len(args) > 1 {
fmt.Printf("WARN: Multiple files are currently not supported. Ignoring: %s", strings.Join(args[1:], ", "))
}
default:
fmt.Printf("Unknown type '%s'\n", paramType)
os.Exit(-1)
}
}