view cmd_dumphtml.go @ 22:8d14bbbedf23

genhtml
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 02 Apr 2020 23:39:55 +0900
parents 1aa824c6b319
children
line wrap: on
line source

package lectable

import (
	"context"
	"errors"
	"io"
	"path/filepath"
)

type cmdDumpHTML struct{}

func (cdh *cmdDumpHTML) name() string {
	return "dumphtml"
}

func (cdh *cmdDumpHTML) description() string {
	return "generate lectable html"
}

func (cdh *cmdDumpHTML) run(ctx context.Context, argv []string, outStream, errStream io.Writer) error {
	if len(argv) == 0 {
		return errors.New("Usage: ./lectable dumphtml lecture.json")
	}
	teacherToURLMap, err := convertStaticTeacherToMap(filepath.Join("static_json", "teacher.json"))
	if err != nil {
		return err
	}
	dlfpdf, err := convertLec(argv[0])
	if err != nil {
		return err
	}
	grlectures, err := convertdumpHTMLSTR(dlfpdf, *teacherToURLMap)
	if err != nil {
		return err
	}
	dumpHTML(grlectures, outStream)
	return nil
}