mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
328e177b66
Former-commit-id: 468ca3f8f493737ea4f465b093a962f11ac374e3 [formerly db359ec78a0866482d3a98e476efd11e0b7a8422] [formerly 8186e0d7d6821753ae8f1c262020cd585d80e1e0 [formerly 11e4bb08b4fc047ad7a54f3e4f244eedf11c322e [formerly0a3184b190
]]] Former-commit-id: d07891eab39c576e217b40d1207f6b9744be90e9 [formerly cefd9ba438e2643405475933f8dbe230fb7c40bd] Former-commit-id: e117bd79abdfebe744ac26e6e12213770eaabb03 Former-commit-id:fd4b52cc05
80 lines
1.6 KiB
Go
Executable File
80 lines
1.6 KiB
Go
Executable File
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
"gopkg.in/urfave/cli.v1"
|
|
)
|
|
|
|
var version string
|
|
var pathToData string
|
|
|
|
func main() {
|
|
app := cli.NewApp()
|
|
app.Name = "cowyo"
|
|
app.Usage = "a simple wiki"
|
|
app.Version = version
|
|
app.Compiled = time.Now()
|
|
app.Action = func(c *cli.Context) error {
|
|
if !c.GlobalBool("debug") {
|
|
turnOffDebugger()
|
|
}
|
|
pathToData = c.GlobalString("data")
|
|
os.MkdirAll(pathToData, 0755)
|
|
fmt.Printf("\nRunning CowYo at http://%s:%s\n\n", GetLocalIP(), c.GlobalString("port"))
|
|
serve(c.GlobalString("port"))
|
|
return nil
|
|
}
|
|
app.Flags = []cli.Flag{
|
|
cli.StringFlag{
|
|
Name: "data",
|
|
Value: "data",
|
|
Usage: "data folder to use",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "olddata",
|
|
Value: "",
|
|
Usage: "data folder for migrating",
|
|
},
|
|
cli.StringFlag{
|
|
Name: "port,p",
|
|
Value: "8050",
|
|
Usage: "port to use",
|
|
},
|
|
cli.BoolFlag{
|
|
Name: "debug, d",
|
|
Usage: "turn on debugging",
|
|
},
|
|
}
|
|
app.Commands = []cli.Command{
|
|
{
|
|
Name: "migrate",
|
|
Aliases: []string{"m"},
|
|
Usage: "migrate from the old cowyo",
|
|
Action: func(c *cli.Context) error {
|
|
if !c.GlobalBool("debug") {
|
|
turnOffDebugger()
|
|
}
|
|
pathToData = c.GlobalString("data")
|
|
pathToOldData := c.GlobalString("olddata")
|
|
if len(pathToOldData) == 0 {
|
|
fmt.Printf("You need to specify folder with -olddata")
|
|
return nil
|
|
}
|
|
os.MkdirAll(pathToData, 0755)
|
|
if !exists(pathToOldData) {
|
|
fmt.Printf("Can not find '%s', does it exist?", pathToOldData)
|
|
return nil
|
|
}
|
|
migrate(pathToOldData, pathToData)
|
|
return nil
|
|
},
|
|
},
|
|
}
|
|
|
|
app.Run(os.Args)
|
|
|
|
}
|