This commit is contained in:
xuthus5 2022-07-22 00:05:59 +08:00
commit 23136281f1
9 changed files with 80 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.vscode/
.idea/
*.exe
go.sum

21
cmd.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "mder",
Short: "mder is a very fast static site generator",
}
)
func init() {
// create a new mder folder
rootCmd.AddCommand(initCmd())
}
func main() {
rootCmd.Execute()
}

1
deploy.go Normal file
View File

@ -0,0 +1 @@
package main

10
go.mod Normal file
View File

@ -0,0 +1,10 @@
module mder
go 1.18
require github.com/spf13/cobra v1.5.0
require (
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)

25
init.go Normal file
View File

@ -0,0 +1,25 @@
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
)
func initCmd() *cobra.Command {
var name string
cmd := &cobra.Command{
Use: "init",
Short: "create a new mder folder",
Run: func(cmd *cobra.Command, args []string) {
if err := cloneTemplate(name); err != nil {
panic(err)
}
_, _ = fmt.Fprintf(os.Stdout, "create folder %s success.\n", name)
},
}
cmd.Flags().StringVar(&name, "name", "mder", "Name of the folder to create")
return cmd
}

1
page.go Normal file
View File

@ -0,0 +1 @@
package main

1
post.go Normal file
View File

@ -0,0 +1 @@
package main

1
serve.go Normal file
View File

@ -0,0 +1 @@
package main

16
utils.go Normal file
View File

@ -0,0 +1,16 @@
package main
import (
"fmt"
"os"
"os/exec"
)
func cloneTemplate(base string) error {
_, err := exec.Command("git", "clone", "https://gitter.top/mder/template", base).Output()
if err != nil {
_, _ = fmt.Fprintf(os.Stderr, "get latest template failed: %v\n", err)
return err
}
return nil
}