- Timestamp:
- Sep 16, 2023, 4:11:35 PM (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cmd/aya/main.go
r69 r70 1 // $TheSupernovaDuo: cmd/aya/main.go,v 0.6. 0 2023/9/13 07:50:00 yakumo_izuru Exp $1 // $TheSupernovaDuo: cmd/aya/main.go,v 0.6.1 2023/9/16 11:43:00 yakumo_izuru Exp $ 2 2 package main 3 3 … … 363 363 } 364 364 365 // Serve the public directory over HTTP and watch for changes365 // Serve the public directory over HTTP 366 366 func serve() { 367 http.Handle("/", http.FileServer(http.Dir(PUBDIR))) 367 root := http.Dir(PUBDIR) 368 http.Handle("/", http.FileServer(root)) 369 log.Printf("Serving the %s directory over http://localhost:8000. Interrupt with ^C.\n", PUBDIR) 368 370 log.Fatal(http.ListenAndServe(":8000", nil)) 369 371 } … … 379 381 // Print usage notes 380 382 func printUsage() { 381 fmt.Printf("%v <command> [args]\n", os.Args[0]) 383 fmt.Printf("Usage: %s <command> [args]\n", os.Args[0]) 384 fmt.Printf("Where <command> is one of\n") 382 385 fmt.Printf("\n") 383 fmt.Printf("Where <command> is:\n") 384 fmt.Printf("\tbuild\tGenerate site\n") 385 fmt.Printf("\tclean\tRemoves the generated site directory\n") 386 fmt.Printf("\tvar\tQuery variable(s) from a markdown file\n") 387 fmt.Printf("\tversion\tPrint program version and exit\n") 388 fmt.Printf("\twatch\t(Re)generate site while looking for changes (it also serves on HTTP)\n") 389 fmt.Printf("\n") 390 fmt.Printf("Other commands may be dynamically added by plugins found in %v\n", AYADIR) 386 fmt.Printf("\tbuild\t(Re-)builds site or a specific file\n") 387 fmt.Printf("\tclean\trm -rf %s\n", PUBDIR) 388 fmt.Printf("\tserve\tServes the %s directory over HTTP\n", PUBDIR) 389 fmt.Printf("\tvar\tPrint a list of variables defined in a given file, or values of certain variables\n") 390 fmt.Printf("\twatch\t(Re-)builds site and looks for changes\n") 391 391 os.Exit(0) 392 392 } … … 414 414 case "help": 415 415 printUsage() 416 case "serve": 417 serve() 416 418 case "var": 417 419 if len(args) == 0 { … … 439 441 case "watch": 440 442 buildAll(true) 441 serve()442 443 default: 443 444 if s, err := run(globals(), cmd, args...); err != nil {
Note:
See TracChangeset
for help on using the changeset viewer.