Пример #1
0
func testIndividualFileYAML(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", ".md", 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.LegalToMarkdown(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
	}

}
Пример #2
0
func cliLegalToMarkdown(c *cli.Context) {

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

	if c.String("output") == "" {
		log.Fatal("Please specify an output file to write to with the --output or -o flag.")
	}

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

	lmd.LegalToMarkdown(contents, parameters, output)
}