func RenderFile(inputFile, outDir, rpkgsDir string, keep bool) { fmt.Println("Rendering", inputFile) if utils.DoesExist(outDir) == false { utils.MakeDirs(outDir, 0755) log.Println("Created output directory:", outDir) } extension := filepath.Ext(inputFile) switch extension { case ".md": fmt.Println("Going to render straight up markdown") RenderMarkdownFile(inputFile, outDir) case ".mkdn": fmt.Println("Going to render straight up markdown") RenderMarkdownFile(inputFile, outDir) case ".markdown": fmt.Println("Going to render straight up markdown") RenderMarkdownFile(inputFile, outDir) case ".Rmd": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) case ".rmd": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) case ".Rmkdn": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) case ".rmkdn": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) case ".Rmarkdown": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) case ".rmarkdown": fmt.Println("Going to render RMarkdown") RenderRMarkdownFile(inputFile, outDir, rpkgsDir, keep) default: log.Fatalf("Don't know how to render file of type: '%s'", extension, ) } }
func setupDir(dir string) { if utils.DoesExist(dir) == false { log.Printf("Creating directory: %s", dir) utils.MakeDirs(dir, 0755) } log.Printf("Setting R_LIBS to: %s", dir) if err := os.Setenv("R_LIBS", dir); err != nil { log.Fatalf( "Could not set R_LIBS: %s", err, ) } Rlibs := os.Getenv("R_LIBS") if Rlibs != dir { log.Fatalln( "Environment Variable 'R_LIBS' isn't correctly set. ", ) } }
func (opts SetupCmdOpts) processOpts() { if (utils.DoesExist(opts.RLibs)) && (opts.Force == false) { log.Fatalf( "R libs directory '%s' already exists."+ "Use '--force' to overwrite, or specify"+ "a different directory", opts.RLibs, ) } if !((opts.InstallType == "pinned") || (opts.InstallType == "dev") || (opts.InstallType == "latest")) { log.Fatalf( "--install option: '%s' isn't a valid type."+ "it has to be either: %s", opts.InstallType, "'pinned', 'dev', or 'latest'", ) } }