Changeset 70 in code for trunk/cmd


Ignore:
Timestamp:
Sep 16, 2023, 4:11:35 PM (21 months ago)
Author:
Izuru Yakumo
Message:

Fix a bug that I caused

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

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 $
    22package main
    33
     
    363363}
    364364
    365 // Serve the public directory over HTTP and watch for changes
     365// Serve the public directory over HTTP
    366366func 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)
    368370        log.Fatal(http.ListenAndServe(":8000", nil))
    369371}
     
    379381// Print usage notes
    380382func 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")
    382385        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")
    391391        os.Exit(0)
    392392}
     
    414414        case "help":
    415415                printUsage()
     416        case "serve":
     417                serve()
    416418        case "var":
    417419                if len(args) == 0 {
     
    439441        case "watch":
    440442                buildAll(true)
    441                 serve()
    442443        default:
    443444                if s, err := run(globals(), cmd, args...); err != nil {
Note: See TracChangeset for help on using the changeset viewer.