39 lines
849 B
Go
39 lines
849 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"os"
|
|
|
|
"gitea.r8z.us/stwhite/paperformatter"
|
|
)
|
|
|
|
func main() {
|
|
// Check if input and output files are provided
|
|
if len(os.Args) != 3 {
|
|
fmt.Println("Usage: go run main.go <input.json> <output.md>")
|
|
fmt.Println("Example: go run main.go input.json output.md")
|
|
os.Exit(1)
|
|
}
|
|
|
|
inputFile := os.Args[1]
|
|
outputFile := os.Args[2]
|
|
|
|
// Format the papers
|
|
err := paperformatter.FormatPapers(inputFile, outputFile)
|
|
if err != nil {
|
|
switch e := err.(type) {
|
|
case *paperformatter.ValidationError:
|
|
log.Fatalf("Validation error: %v", e)
|
|
case *paperformatter.FileError:
|
|
log.Fatalf("File error: %v", e)
|
|
case *paperformatter.JSONError:
|
|
log.Fatalf("JSON error: %v", e)
|
|
default:
|
|
log.Fatalf("Error: %v", err)
|
|
}
|
|
}
|
|
|
|
fmt.Printf("Successfully formatted papers from %s to %s\n", inputFile, outputFile)
|
|
}
|