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