mirror of
https://github.com/schollz/cowyo.git
synced 2023-08-10 21:13:00 +03:00
8a7803250f
Former-commit-id: 807d525f11b5306c2a4a2e7097a8d92d026fc9df [formerly 9c40fcf478e90dd062c9a173b4d563a4ba15b8bc] [formerly 0c56b23e0782fe14717c243d149983185fe9ad2d [formerly 7f4acdda9a
]]
Former-commit-id: 71ae3d9712ec1b7203e6483ad586aeef319fba08 [formerly e633558e9a7491044e324ceeb2cb699b2130f1c8]
Former-commit-id: 8e483f94bf5c75d62d00219085d1e68c4e5683c7
77 lines
1.5 KiB
Go
Executable File
77 lines
1.5 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 = "linkcrawler"
|
|
app.Usage = "crawl a site for links, or download a list of sites"
|
|
app.Version = version
|
|
app.Compiled = time.Now()
|
|
app.Action = func(c *cli.Context) error {
|
|
cli.ShowSubcommandHelp(c)
|
|
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.BoolFlag{
|
|
Name: "debug, d",
|
|
Usage: "turn on debugging",
|
|
},
|
|
}
|
|
app.Commands = []cli.Command{
|
|
{
|
|
Name: "serve",
|
|
Aliases: []string{"s"},
|
|
Usage: "start a cowyo server",
|
|
Action: func(c *cli.Context) error {
|
|
pathToData = c.GlobalString("data")
|
|
os.MkdirAll(pathToData, 0755)
|
|
serve()
|
|
return nil
|
|
},
|
|
},
|
|
{
|
|
Name: "migrate",
|
|
Aliases: []string{"m"},
|
|
Usage: "migrate from the old cowyo",
|
|
Action: func(c *cli.Context) error {
|
|
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)
|
|
|
|
}
|