diff --git a/cmd/cdr/generate.go b/cmd/cdr/generate.go index 3919932..f59d668 100644 --- a/cmd/cdr/generate.go +++ b/cmd/cdr/generate.go @@ -17,6 +17,11 @@ var ( Usage: "serve the mixtape site", Action: serveAction, } + cmdGenerate = cli.Command{ + Name: "burn", + Usage: "generate the static mixtape site", + Action: generateAction, + } ) func newMixtape(wd string) (*cdr.Mixtape, error) { @@ -38,6 +43,31 @@ func newMixtape(wd string) (*cdr.Mixtape, error) { return m, nil } +func generateAction(c *cli.Context) error { + f, err := os.Create("index.html") + if err != nil { + return err + } + defer f.Close() + + wd, err := os.Getwd() + if err != nil { + return err + } + + m, err := newMixtape(wd) + if err != nil { + return err + } + + err = cdr.Render(m, f) + if err != nil { + return err + } + + return nil +} + func serveAction(c *cli.Context) error { wd, err := os.Getwd() if err != nil { diff --git a/cmd/cdr/main.go b/cmd/cdr/main.go index 6bd543a..57f38c8 100644 --- a/cmd/cdr/main.go +++ b/cmd/cdr/main.go @@ -16,6 +16,7 @@ func main() { } app.Commands = []*cli.Command{ + &cmdGenerate, &cmdServe, &cmdClean, }