func testIndividualFileHeaders(file string) bool {
	// announce thyself
	fmt.Println(CLR_0, "Testing file: ", file, CLR_N)

	// set the basis and read it into memory
	basisFile := strings.Replace(file, ".lmd", ".headers", 1)
	testAgainstMe := lmd.ReadAFile(basisFile)

	// make a temp file
	tempFile, tempFileErr := ioutil.TempFile(os.TempDir(), "lmd-test-")
	if tempFileErr != nil {
		log.Fatal(tempFileErr)
	}
	defer os.Remove(tempFile.Name())

	// run LegalToMarkdown on the fixture
	lmd.MakeYAMLFrontMatter(file, "", tempFile.Name())

	// read the tempfile
	iMadeThisFile := lmd.ReadAFile(tempFile.Name())

	// announce
	if testAgainstMe == iMadeThisFile {
		fmt.Println(CLR_G, "YES!\n", CLR_N)
		return true
	} else {
		fmt.Println(CLR_R, "NOOOOOOOOOOOOOOOOO.\n", CLR_N)
		fmt.Println(CLR_G, "Expected =>", CLR_N)
		fmt.Println(testAgainstMe)
		fmt.Println(CLR_R, "Result =>", CLR_N)
		fmt.Println(iMadeThisFile)
		return false
	}

}
Beispiel #2
0
func cliMakeYAMLFrontMatter(c *cli.Context) {

	if c.String("template") == "" {
		log.Fatal("Please specify a template file to parse with the --template or -t flag.")
	}

	contents := c.String("template")
	parameters := c.String("parameters")
	output := c.String("output")

	lmd.MakeYAMLFrontMatter(contents, parameters, output)
}