mirror of
https://github.com/vbatts/sl-feeds.git
synced 2024-11-22 07:45:39 +00:00
main: add the --quiet flag
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
parent
fc518b86c5
commit
dc39b5bdc7
1 changed files with 16 additions and 4 deletions
|
@ -29,6 +29,10 @@ func main() {
|
|||
Name: "dest, d",
|
||||
Usage: "Output RSS files to `DIR`",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "quiet, q",
|
||||
Usage: "Less output",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "sample-config",
|
||||
Usage: "Output sample config file to stdout",
|
||||
|
@ -40,6 +44,7 @@ func main() {
|
|||
if c.Bool("sample-config") {
|
||||
c := Config{
|
||||
Dest: "$HOME/public_html/feeds/",
|
||||
Quiet: false,
|
||||
Mirrors: []Mirror{
|
||||
Mirror{
|
||||
URL: "http://slackware.osuosl.org/",
|
||||
|
@ -76,7 +81,9 @@ func main() {
|
|||
}
|
||||
|
||||
dest := os.ExpandEnv(config.Dest)
|
||||
if !c.Bool("quiet") {
|
||||
fmt.Printf("Writing to: %q\n", dest)
|
||||
}
|
||||
/*
|
||||
for each mirror in Mirrors
|
||||
if there is not a $release.RSS file, then fetch the whole ChangeLog
|
||||
|
@ -90,7 +97,9 @@ func main() {
|
|||
Release: release,
|
||||
}
|
||||
|
||||
if !c.Bool("quiet") {
|
||||
log.Printf("processing %q", repo.URL+"/"+repo.Release)
|
||||
}
|
||||
|
||||
stat, err := os.Stat(filepath.Join(dest, mirror.Prefix+release+".rss"))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
|
@ -111,7 +120,9 @@ func main() {
|
|||
// compare times
|
||||
entries, mtime, err = repo.NewerChangeLog(stat.ModTime())
|
||||
if err != nil {
|
||||
if !(err == fetch.ErrNotNewer && c.Bool("quiet")) {
|
||||
log.Println(release, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
@ -167,6 +178,7 @@ func main() {
|
|||
// Config is read in to point to where RSS are written to, and the Mirrors to
|
||||
// be fetched from
|
||||
type Config struct {
|
||||
Quiet bool
|
||||
Dest string
|
||||
Mirrors []Mirror
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue