GenGo

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 472b849be6ecf273e5da291e8af41f9ecabac08e
parent 0d38e7bfd14a73dd2be0e186c140a84ac4e112de
Author: Tyler Clark <tyler.clark@foxide.xyz>
Date:   Sun,  4 Jan 2026 21:04:06 -0500

Adding the ability to actually convert files

Diffstat:
Mmain.go | 36+++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/main.go b/main.go @@ -5,22 +5,26 @@ /* TODO: Basic functionality for converting markdown/org to html */ /* TODO: Mirroring dir structure of source files */ /* TODO: RSS generator built in */ +/* TODO: Sitemap generator */ /*****************************************************************/ /* LAYOUT OF CLI: */ /* gengo ${SRC} ${DEST} ${DOMAIN} [optional args] */ /*****************************************************************/ /* OPTIONAL ARGUMENTS: */ -/* TODO -r: Do not generate RSS feed */ -/* TODO -s: Do not generate sitemap */ -/* DONE -v: Show program version number */ -/* PROG -h: Display help */ +/* TODO -j: Set how many concurrent jobs can run */ +/* PROG -h: Display help */ +/* TODO -r: Do not generate RSS feed */ +/* TODO -s: Do not generate sitemap */ +/* DONE -v: Show program version number */ /*****************************************************************/ package main import ( - "fmt" // For formatting some outputs - "os" // File system and arguments + "fmt" // For formatting some outputs + "os" // File system and arguments + "os/exec" // For running OS operations + "path" // For removing file extensions ) /* Release version */ @@ -32,10 +36,26 @@ func ValidateFile(filename string) { fmt.Fprintln(os.Stderr, "No file found") os.Exit(1) } else { - fmt.Println("File exists.") + ConvertFile(filename) } } +func RemoveExt(filename string) string { + return filename[:len(filename)-len(path.Ext(filename))] +} + +func ConvertFile(filename string) { + fmt.Println("Converting following file to HTML:", filename) + oFile := RemoveExt(filename) + cmd := exec.Command("pandoc", filename, "-o", oFile + ".html") + output, err := cmd.Output() + if err != nil { + fmt.Println("Error:", err) + return + } + fmt.Println(string(output)) +} + func callHelp() { println("One day this will be a useful help message") } @@ -48,8 +68,10 @@ func ArgParser (argument[] string) { switch argument[i] { case "-h", "--help": callHelp() + os.Exit(0) case "-v", "--version": println("Version:", version) + os.Exit(0) default: ValidateFile(argument[i]) }