2024-03-01 00:23:26 +03:00
|
|
|
package rwiki
|
|
|
|
|
|
|
|
import (
|
|
|
|
"vultras.su/core/cli/mtool"
|
|
|
|
"vultras.su/core/bond"
|
|
|
|
"vultras.su/service/rwiki/server"
|
|
|
|
"log"
|
|
|
|
)
|
|
|
|
|
|
|
|
var Tool = mtool.T("rwiki").Func(func(flags *mtool.Flags){
|
|
|
|
var (
|
|
|
|
addr string
|
|
|
|
opts server.ServerOptions
|
|
|
|
)
|
|
|
|
flags.StringVar(&addr, "a", ":8080", "address string")
|
|
|
|
flags.StringVar(&opts.WikiPath, "wiki", "wiki", "path to wiki files")
|
|
|
|
flags.StringVar(&opts.WebPath, "web", "web", "path to static web files")
|
2024-03-01 03:36:45 +03:00
|
|
|
flags.StringVar(&opts.WikiExt, "ext", ".pmd", "wiki file exitension")
|
|
|
|
flags.BoolVar(&opts.AddFileNavigation, "nav", true, "generate navigation")
|
2024-03-01 00:23:26 +03:00
|
|
|
|
|
|
|
flags.Parse()
|
|
|
|
srv := bond.Server{
|
|
|
|
Addr: addr,
|
|
|
|
Handler: bond.Root(server.New(opts)),
|
|
|
|
}
|
|
|
|
log.Println("Serving at ", addr)
|
|
|
|
err := srv.ListenAndServe()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
})
|