summaryrefslogtreecommitdiff
path: root/main.go
blob: 7a3bb88a3027a703238d38a19e8cbb6b8423b5cd (plain)
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
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"

	"github.com/Shugyousha/stasher/conf"
	"github.com/Shugyousha/stasher/filter"
	"github.com/Shugyousha/stasher/input"
	"github.com/Shugyousha/stasher/output"
)

func main() {
	f, err := os.Open("stasher.cfg")
	if err != nil {
		fmt.Fprintf(os.Stderr, "Could not open config file 'stasher.cfg': %q\n", err)
		os.Exit(1)
	}

	c := conf.NewConfig(bufio.NewReader(f))
	fmt.Fprintf(os.Stderr, "config: %#v\n", c)

	ffmap := make(map[string]func(string) string, 10)
	ffmap["F"] = func(s string) string { return strings.ToUpper(s) }

	m := Manager{
		Input:  input.NewStdin(),
		Filter: filter.NewStringFilter(ffmap),
		Output: &output.StdoutOutput{},
	}

	m.Run()
}