-
Notifications
You must be signed in to change notification settings - Fork 8
/
html.go
49 lines (40 loc) · 1.2 KB
/
html.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
package cli
import (
"io"
"github.com/eprovst/wrap/pkg/ast"
"github.com/eprovst/wrap/pkg/html"
"github.com/spf13/cobra"
)
// htmlCmd represents the html command
var htmlCmd = &cobra.Command{
Use: "html [path to input file]",
Example: " wrap html MyScript.fountain\n cat OtherScript.wrap | wrap html",
Short: "Export file as an HTML webpage",
Args: cobra.MaximumNArgs(1),
TraverseChildren: true,
Long: longDescription,
Run: htmlRun,
}
var (
htmlEmbedableFlag bool
htmlProductionFlag bool
)
func init() {
htmlCmd.Flags().BoolVarP(&htmlEmbedableFlag, "embedable", "e", false, "only output the play itself")
htmlCmd.Flags().BoolVarP(&htmlProductionFlag, "production", "p", false, "remove scene numbers from output")
WrapCmd.AddCommand(htmlCmd)
}
func htmlRun(cmd *cobra.Command, args []string) {
html.Production = htmlProductionFlag
if htmlEmbedableFlag {
export(args, "html", func(script *ast.Script, buffer io.Writer) error {
html.WriteHTML(script, buffer)
return nil
})
} else {
export(args, "html", func(script *ast.Script, buffer io.Writer) error {
html.WriteHTMLPage(script, buffer)
return nil
})
}
}