-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_presenter.go
36 lines (29 loc) · 1003 Bytes
/
create_presenter.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
package cmd
import (
"fmt"
"github.com/wagoodman/go-presenter"
"github.com/nextlinux/chronicle/chronicle/release"
"github.com/nextlinux/chronicle/chronicle/release/format"
"github.com/nextlinux/chronicle/chronicle/release/format/json"
"github.com/nextlinux/chronicle/chronicle/release/format/markdown"
)
type presentationTask func(description release.Description) (presenter.Presenter, error)
func selectPresenter(f format.Format) (presentationTask, error) {
switch f {
case format.MarkdownFormat:
return presentMarkdown, nil
case format.JSONFormat:
return presentJSON, nil
default:
return nil, fmt.Errorf("unsupported output format: %+v", f)
}
}
func presentMarkdown(description release.Description) (presenter.Presenter, error) {
return markdown.NewMarkdownPresenter(markdown.Config{
Description: description,
Title: appConfig.Title,
})
}
func presentJSON(description release.Description) (presenter.Presenter, error) {
return json.NewJSONPresenter(description)
}