Fix a bug that I caused

Signed-off-by: Izuru Yakumo <yakumo.izuru@chaotic.ninja>

git-svn-id: file:///srv/svn/repo/aya/trunk@70 cec141ff-132a-4243-88a5-ce187bd62f94
This commit is contained in:
yakumo.izuru
2023-09-16 16:11:35 +00:00
parent 7e18021266
commit b85b718448
3 changed files with 31 additions and 21 deletions

View File

@@ -1,4 +1,4 @@
// $TheSupernovaDuo: cmd/aya/main.go,v 0.6.0 2023/9/13 07:50:00 yakumo_izuru Exp $
// $TheSupernovaDuo: cmd/aya/main.go,v 0.6.1 2023/9/16 11:43:00 yakumo_izuru Exp $
package main
import (
@@ -362,9 +362,11 @@ func buildAll(watch bool) {
}
}
// Serve the public directory over HTTP and watch for changes
// Serve the public directory over HTTP
func serve() {
http.Handle("/", http.FileServer(http.Dir(PUBDIR)))
root := http.Dir(PUBDIR)
http.Handle("/", http.FileServer(root))
log.Printf("Serving the %s directory over http://localhost:8000. Interrupt with ^C.\n", PUBDIR)
log.Fatal(http.ListenAndServe(":8000", nil))
}
@@ -378,16 +380,14 @@ func init() {
// Print usage notes
func printUsage() {
fmt.Printf("%v <command> [args]\n", os.Args[0])
fmt.Printf("Usage: %s <command> [args]\n", os.Args[0])
fmt.Printf("Where <command> is one of\n")
fmt.Printf("\n")
fmt.Printf("Where <command> is:\n")
fmt.Printf("\tbuild\tGenerate site\n")
fmt.Printf("\tclean\tRemoves the generated site directory\n")
fmt.Printf("\tvar\tQuery variable(s) from a markdown file\n")
fmt.Printf("\tversion\tPrint program version and exit\n")
fmt.Printf("\twatch\t(Re)generate site while looking for changes (it also serves on HTTP)\n")
fmt.Printf("\n")
fmt.Printf("Other commands may be dynamically added by plugins found in %v\n", AYADIR)
fmt.Printf("\tbuild\t(Re-)builds site or a specific file\n")
fmt.Printf("\tclean\trm -rf %s\n", PUBDIR)
fmt.Printf("\tserve\tServes the %s directory over HTTP\n", PUBDIR)
fmt.Printf("\tvar\tPrint a list of variables defined in a given file, or values of certain variables\n")
fmt.Printf("\twatch\t(Re-)builds site and looks for changes\n")
os.Exit(0)
}
@@ -413,6 +413,8 @@ func main() {
os.RemoveAll(PUBDIR)
case "help":
printUsage()
case "serve":
serve()
case "var":
if len(args) == 0 {
log.Fatal("var: filename expected")
@@ -438,7 +440,6 @@ func main() {
os.Exit(0)
case "watch":
buildAll(true)
serve()
default:
if s, err := run(globals(), cmd, args...); err != nil {
log.Println(err)