-
Notifications
You must be signed in to change notification settings - Fork 154
/
Copy pathconvert.go
59 lines (51 loc) · 1.15 KB
/
convert.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
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"log"
"github.com/ma6254/FictionDown/output"
"github.com/urfave/cli"
)
var convert = cli.Command{
Name: "convert",
Usage: "转换格式输出",
Aliases: []string{"conv"},
Flags: []cli.Flag{
cli.StringFlag{
Name: "f",
Usage: "输出格式",
},
cli.StringFlag{
Name: "o",
Usage: "输出路径",
},
cli.BoolFlag{
Name: "ignore_cover",
Usage: "忽略封面",
Destination: &outputOpt.IgnoreCover,
},
cli.BoolFlag{
Name: "no-EPUB-metadata",
Usage: "禁用EPUB元数据",
Destination: &outputOpt.NoEPUBMetadata,
},
},
Action: func(c *cli.Context) error {
if err := initLoadStore(c); err != nil {
return err
}
var (
format = c.String("f")
outputpath = c.String("o")
)
if format == "" {
return nil
}
ConversionFileName := outputpath
if outputpath == "" {
ConversionFileName = fmt.Sprintf("%s.%s", chapter.BookName, format)
}
log.Printf("Start Conversion: Format:%#v OutPath:%#v", c.String("f"), ConversionFileName)
return output.Output(*chapter, format, ConversionFileName, outputOpt)
},
}
var outputOpt output.Option