-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcmd_push.go
47 lines (39 loc) · 845 Bytes
/
cmd_push.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
package kibelasync
import (
"context"
"flag"
"io"
"github.com/Songmu/kibelasync/kibela"
"golang.org/x/xerrors"
)
type cmdPush struct{}
func (cp *cmdPush) name() string {
return "push"
}
func (cp *cmdPush) description() string {
return "push markdown"
}
func (cp *cmdPush) run(ctx context.Context, argv []string, outStream io.Writer, errStream io.Writer) error {
fs := flag.NewFlagSet("kibelasync push", flag.ContinueOnError)
fs.SetOutput(errStream)
if err := fs.Parse(argv); err != nil {
return err
}
ki, err := kibela.New(version)
if err != nil {
return err
}
if fs.NArg() < 1 {
return xerrors.New("usage: kibelasync push [md files]")
}
for _, f := range fs.Args() {
md, err := kibela.LoadMD(f)
if err != nil {
return err
}
if err := ki.PushMD(ctx, md); err != nil {
return err
}
}
return nil
}