summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvan Jegen <s.jegen@gmail.com>2017-01-22 16:17:34 +0100
committerSilvan Jegen <s.jegen@gmail.com>2017-01-22 16:17:34 +0100
commit51bd6e455dea5c22f8a5c4d1579c472c4937e8d6 (patch)
treea01a17e1b88f7047e45dbbad6dd13275f3a97e34
parent17a03b66a4a389a13e2187840bb1c1da9041f55b (diff)
Use registry for output modules
-rw-r--r--main.go4
-rw-r--r--output/outputinterface.go (renamed from output/interface.go)0
-rw-r--r--output/stdout.go14
-rw-r--r--output/stdout/stdout.go24
-rw-r--r--registry/registry.go8
5 files changed, 28 insertions, 22 deletions
diff --git a/main.go b/main.go
index 5b0e329..69677d5 100644
--- a/main.go
+++ b/main.go
@@ -9,7 +9,7 @@ import (
"github.com/Shugyousha/stasher/conf"
"github.com/Shugyousha/stasher/filter/str"
"github.com/Shugyousha/stasher/input/stdin"
- "github.com/Shugyousha/stasher/output"
+ "github.com/Shugyousha/stasher/output/stdout"
)
func main() {
@@ -28,7 +28,7 @@ func main() {
m := Manager{
Input: stdin.New(nil),
Filter: str.New(ffmap),
- Output: &output.StdoutOutput{},
+ Output: stdout.New(nil),
}
m.Run()
diff --git a/output/interface.go b/output/outputinterface.go
index 8f1137a..8f1137a 100644
--- a/output/interface.go
+++ b/output/outputinterface.go
diff --git a/output/stdout.go b/output/stdout.go
deleted file mode 100644
index 5cb753e..0000000
--- a/output/stdout.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package output
-
-import (
- "fmt"
-
- "github.com/Shugyousha/stasher/work"
-)
-
-type StdoutOutput struct {
-}
-
-func (o *StdoutOutput) Output(w *work.Work) {
- fmt.Printf("%s\n", w.Data)
-}
diff --git a/output/stdout/stdout.go b/output/stdout/stdout.go
new file mode 100644
index 0000000..9d66581
--- /dev/null
+++ b/output/stdout/stdout.go
@@ -0,0 +1,24 @@
+package stdout
+
+import (
+ "fmt"
+
+ "github.com/Shugyousha/stasher/output"
+ "github.com/Shugyousha/stasher/registry"
+ "github.com/Shugyousha/stasher/work"
+)
+
+func init() {
+ registry.Outputregistry["stdout"] = New
+}
+
+type StdoutOutput struct {
+}
+
+func New(map[string]string) output.Output {
+ return &StdoutOutput{}
+}
+
+func (o *StdoutOutput) Output(w *work.Work) {
+ fmt.Printf("%s\n", w.Data)
+}
diff --git a/registry/registry.go b/registry/registry.go
index 7f0149f..6bb99f0 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -3,15 +3,11 @@ package registry
import (
"github.com/Shugyousha/stasher/filter"
"github.com/Shugyousha/stasher/input"
- "github.com/Shugyousha/stasher/work"
+ "github.com/Shugyousha/stasher/output"
)
var (
Inputregistry map[string]func(map[string]string) input.Input = make(map[string]func(map[string]string) input.Input)
Filterregistry map[string]func(map[string]string) filter.Filter = make(map[string]func(map[string]string) filter.Filter)
- Outputregistry map[string]func(map[string]string) Output = make(map[string]func(map[string]string) Output)
+ Outputregistry map[string]func(map[string]string) output.Output = make(map[string]func(map[string]string) output.Output)
)
-
-type Output interface {
- Output(*work.Work)
-}