-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from cabalism/fix/pkg-counts-15
Add package counts
- Loading branch information
Showing
6 changed files
with
96 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ dep-counts = ./comments/dep-counts.dhall | ||
, intros = ./comments/intros.dhall | ||
, pkg-counts = ./comments/pkg-counts.dhall | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
let TYPES = ../../../types.dhall | ||
|
||
let L = https://prelude.dhall-lang.org/List/package.dhall | ||
|
||
let N = https://prelude.dhall-lang.org/Natural/package.dhall | ||
|
||
in \(verbosity : TYPES.Verbosity) -> | ||
\(pkg-set : TYPES.PkgSet) -> | ||
\(format-comments : List Text -> Text) -> | ||
let pkgs = | ||
merge | ||
{ AllPkgs = \(pkgs : List Text) -> pkgs | ||
, PkgUpgrade = \(pkgs : TYPES.PkgTodoList) -> pkgs.done | ||
} | ||
pkg-set | ||
|
||
in merge | ||
{ Quiet = "" | ||
, Info = | ||
let comments = | ||
merge | ||
{ AllPkgs = | ||
\(pkgs : List Text) -> | ||
let count-pkgs = L.length Text pkgs | ||
|
||
in if N.isZero count-pkgs | ||
then [ "We have no packages" ] | ||
else let package-or-packages = | ||
if N.equal 1 count-pkgs | ||
then "package" | ||
else "packages" | ||
|
||
in [ "We have ${N.show | ||
count-pkgs} ${package-or-packages}." | ||
] | ||
, PkgUpgrade = | ||
\(pkgs : TYPES.PkgTodoList) -> | ||
let count-done = L.length Text pkgs.done | ||
|
||
let count-todo = L.length Text pkgs.todo | ||
|
||
let package-or-packages = | ||
if N.equal 1 count-done | ||
then "package" | ||
else "packages" | ||
|
||
in [ "We have upgraded ${N.show | ||
count-done} ${package-or-packages} and have ${N.show | ||
count-todo} yet to do." | ||
] | ||
} | ||
pkg-set | ||
|
||
in format-comments comments | ||
} | ||
verbosity |