Implement CLI mode and Markdown parsing

- Add CLI mode distinction (gocv vs gocv serve)
- Add goldmark dependency for Markdown parsing
- Create content reading logic from ./content directory
- Implement Markdown to HTML conversion
- Add sample content/index.md for testing
- Update .gitignore for build artifacts

Co-Authored-By: Claude (glm-5) <noreply@anthropic.com>
This commit is contained in:
2026-03-05 02:13:16 +01:00
parent 70ca2e50e5
commit a1d054dfe4
7 changed files with 179 additions and 11 deletions

42
main.go
View File

@@ -13,15 +13,49 @@ var APP_VERSION string = "latest"
var COMMIT_ID string = "undefined"
var ws *WebServer
func main() {
// Create a channel to receive the OS signals
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)
const (
contentPath = "./content"
outputPath = "./output"
)
func main() {
// Initialize the WebService structure
ws = new(WebServer)
ws.Initialize()
// Determine mode based on command line argument
// No CLI flags - just check os.Args
if len(os.Args) > 1 && os.Args[1] == "serve" {
// Serve mode: Start HTTP server with file watching
runServeMode()
} else {
// CLI mode: Generate static files and exit
runCLIMode()
}
}
func runCLIMode() {
fmt.Println("Running in CLI mode...")
fmt.Printf("Reading content from: %s\n", contentPath)
fmt.Printf("Writing output to: %s\n", outputPath)
// Read content and generate output
err := generateOutput()
if err != nil {
fmt.Printf("Error generating output: %s\n", err)
os.Exit(1)
}
fmt.Println("Generation complete.")
}
func runServeMode() {
fmt.Println("Running in Serve mode...")
// Create a channel to receive the OS signals
sc := make(chan os.Signal, 1)
signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)
// Start the WebService in a separate goroutine
go ws.Start()