Merge pull request #423 from Morganamilo/docnews
Document news and use build date over install date
This commit is contained in:
3 files changed
+24
-13
No files matched your search
@@ -119,6 +119,19 @@ be displayed\&.
|
||||
.RS 4
|
||||
Print Names of packages that need to be updated\&. Note this does not perform
|
||||
a database refresh\&. Run \fByay -Sy\fR Before this for an up to date result\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-w --news\fR
|
||||
.RS 4
|
||||
Print new news from the Archlinux homepage\&. News is considered new if it is
|
||||
newer than the build date of all native packages\&. Pass this twice to show all
|
||||
avaliable news\&.
|
||||
.RE
|
||||
.PP
|
||||
\fB\-q --quiet\fR
|
||||
.RS 4
|
||||
Only show titles when printing news\&.
|
||||
.RE
|
||||
.PP
|
||||
.SH "PERMANENT CONFIGURATION SETTINGS"
|
||||
.PP
|
||||
|
||||
@@ -425,7 +425,7 @@ type Item struct {
|
||||
Creator string `xml:"dc:creator"`
|
||||
}
|
||||
|
||||
func (item Item) Print(installTime time.Time) {
|
||||
func (item Item) Print(buildTime time.Time) {
|
||||
var fd string
|
||||
date, err := time.Parse(time.RFC1123Z, item.PubDate)
|
||||
|
||||
@@ -433,8 +433,8 @@ func (item Item) Print(installTime time.Time) {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fd = formatTime(int(date.Unix()))
|
||||
if _, double, _ := cmdArgs.getArg("news", "w"); !double && !installTime.IsZero() {
|
||||
if installTime.After(date) {
|
||||
if _, double, _ := cmdArgs.getArg("news", "w"); !double && !buildTime.IsZero() {
|
||||
if buildTime.After(date) {
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -484,18 +484,18 @@ func printNewsFeed() error {
|
||||
return err
|
||||
}
|
||||
|
||||
installTime, err := lastInstallTime()
|
||||
buildTime, err := lastBuildTime()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if config.SortMode == BottomUp {
|
||||
for i := len(rss.Channel.Items) - 1; i >= 0; i-- {
|
||||
rss.Channel.Items[i].Print(installTime)
|
||||
rss.Channel.Items[i].Print(buildTime)
|
||||
}
|
||||
} else {
|
||||
for i := 0; i < len(rss.Channel.Items); i++ {
|
||||
rss.Channel.Items[i].Print(installTime)
|
||||
rss.Channel.Items[i].Print(buildTime)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -408,22 +408,20 @@ func hangingPackages(removeOptional bool) (hanging []string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func lastInstallTime() (time.Time, error) {
|
||||
func lastBuildTime() (time.Time, error) {
|
||||
var time time.Time
|
||||
|
||||
localDb, err := alpmHandle.LocalDb()
|
||||
pkgs, _, _, _, err := filterPackages()
|
||||
if err != nil {
|
||||
return time, err
|
||||
}
|
||||
|
||||
localDb.PkgCache().ForEach(func(pkg alpm.Package) error {
|
||||
thisTime := pkg.InstallDate()
|
||||
for _, pkg := range pkgs {
|
||||
thisTime := pkg.BuildDate()
|
||||
if thisTime.After(time) {
|
||||
time = thisTime
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
return time, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user