view cmd_dumphtml.go @ 24:841aedb7bbfd

update
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Fri, 03 Apr 2020 07:45:03 +0900
parents 8d14bbbedf23
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
}