1
0
Fork 0
mirror of https://github.com/vbatts/sl-feeds.git synced 2025-07-02 23:18:30 +00:00
sl-feeds/cmd/sl-feeds/main.go
Vincent Batts 98d14f9b91
cmd/sl-feeds: stubbing out a cli
vendoring the deps for the sake of posterity

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2017-01-26 21:07:49 -05:00

68 lines
1.1 KiB
Go

package main
import (
"fmt"
"io/ioutil"
"os"
_ "../../fetch"
"github.com/BurntSushi/toml"
"github.com/urfave/cli"
)
func main() {
config := Config{}
app := cli.NewApp()
app.Name = "sl-feeds"
app.Usage = "Transform slackware ChangeLog.txt into RSS feeds"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
Usage: "Load configuration from `FILE`",
},
cli.StringFlag{
Name: "dest, d",
Usage: "Output RSS files to `DIR`",
},
cli.BoolFlag{
Name: "sample-config",
Usage: "Output sample config file to stdout",
},
}
app.Action = func(c *cli.Context) error {
if c.Bool("sample-config") {
c := Config{
Dest: "./public_html/feeds/",
}
toml.NewEncoder(os.Stdout).Encode(c)
return nil
}
fmt.Println("boom! I say!")
fmt.Println(config)
return nil
}
app.Before = func(c *cli.Context) error {
if c.String("config") == "" {
return nil
}
data, err := ioutil.ReadFile(c.String("config"))
if err != nil {
return err
}
if _, err := toml.Decode(string(data), &config); err != nil {
return err
}
return nil
}
app.Run(os.Args)
}
type Config struct {
Dest string
}