Sending Webmentions #10

Merged
h4kor merged 18 commits from webmention into master 2022-09-06 19:49:00 +00:00
2 changed files with 40 additions and 6 deletions
Showing only changes of commit e9ee59d2ec - Show all commits

38
cmd/owl/init.go Normal file
View File

@ -0,0 +1,38 @@
package main
import (
"h4kor/owl-blogs"
"github.com/spf13/cobra"
)
var domain string
var singleUser string
var unsafe bool
func init() {
rootCmd.AddCommand(initCmd)
initCmd.PersistentFlags().StringVar(&domain, "domain", "http://localhost:8080", "Domain to use")
initCmd.PersistentFlags().StringVar(&singleUser, "single-user", "", "Use single user mode with given username")
initCmd.PersistentFlags().BoolVar(&unsafe, "unsafe", false, "Allow raw html")
}
var initCmd = &cobra.Command{
Use: "init",
Short: "Creates a new repository",
Long: `Creates a new repository`,
Run: func(cmd *cobra.Command, args []string) {
_, err := owl.CreateRepository(repoPath, owl.RepoConfig{
Domain: domain,
SingleUser: singleUser,
AllowRawHtml: unsafe,
})
if err != nil {
println("Error creating repository: ", err.Error())
} else {
println("Repository created: ", repoPath)
}
},
}

View File

@ -7,15 +7,11 @@ import (
) )
var port int var port int
var unsafe bool
var user string
func init() { func init() {
rootCmd.AddCommand(webCmd) rootCmd.AddCommand(webCmd)
rootCmd.PersistentFlags().IntVar(&port, "port", 8080, "Port to use") webCmd.PersistentFlags().IntVar(&port, "port", 8080, "Port to use")
rootCmd.PersistentFlags().BoolVar(&unsafe, "unsafe", false, "Allow unsafe html")
rootCmd.PersistentFlags().StringVar(&user, "user", "", "Start server in single user mode.")
} }
var webCmd = &cobra.Command{ var webCmd = &cobra.Command{
@ -23,6 +19,6 @@ var webCmd = &cobra.Command{
Short: "Start the web server", Short: "Start the web server",
Long: `Start the web server`, Long: `Start the web server`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
web.StartServer(repoPath, port, unsafe, user) web.StartServer(repoPath, port)
}, },
} }