remove old cli

webmention
Niko Abeler 5 months ago
parent 0766101ff6
commit 57d6a93014
  1. 71
      cmd/owl-cli/main.go
  2. 4
      cmd/owl/main.go

@ -1,71 +0,0 @@
package main
import (
"h4kor/owl-blogs"
"os"
)
func main() {
println("owl blogs")
println("Commands")
println("init <repo> - Creates a new repository")
println("<repo> new-user <name> - Creates a new user")
println("<repo> new-post <user> <title> - Creates a new post")
if len(os.Args) < 3 {
println("Please specify a repository and command")
os.Exit(1)
}
if os.Args[1] == "init" {
repoName := os.Args[2]
_, err := owl.CreateRepository(repoName)
if err != nil {
println("Error creating repository: ", err.Error())
}
println("Repository created: ", repoName)
os.Exit(0)
}
repoName := os.Args[1]
repo, err := owl.OpenRepository(repoName)
if err != nil {
println("Error opening repository: ", err.Error())
os.Exit(1)
}
switch os.Args[2] {
case "new-user":
if len(os.Args) < 4 {
println("Please specify a user name")
os.Exit(1)
}
userName := os.Args[3]
user, err := repo.CreateUser(userName)
if err != nil {
println("Error creating user: ", err.Error())
os.Exit(1)
}
println("User created: ", user.Name())
case "new-post":
if len(os.Args) < 5 {
println("Please specify a user name and a title")
os.Exit(1)
}
userName := os.Args[3]
user, err := repo.GetUser(userName)
if err != nil {
println("Error finding user: ", err.Error())
os.Exit(1)
}
title := os.Args[4]
post, err := user.CreateNewPost(title)
if err != nil {
println("Error creating post: ", err.Error())
os.Exit(1)
}
println("Post created: ", post.Title())
default:
println("Unknown command: ", os.Args[2])
os.Exit(1)
}
}

@ -11,8 +11,6 @@ var repoPath string
var rootCmd = &cobra.Command{
Use: "owl",
Short: "Owl Blogs is a not so static blog generator",
// Run: func(cmd *cobra.Command, args []string) {
// },
}
func Execute() {
@ -25,7 +23,7 @@ func Execute() {
func init() {
rootCmd.PersistentFlags().StringVar(&repoPath, "repo", ".", "Path to the repository to use.")
rootCmd.PersistentFlags().StringVar(&user, "user", "", "Username")
rootCmd.PersistentFlags().StringVar(&user, "user", "", "Username. Required for some commands.")
}

Loading…
Cancel
Save