mirror of
https://github.com/jorgebucaran/fisher
synced 2024-07-02 23:11:48 +02:00
refactor: improve readability of status report generator
This commit is contained in:
parent
32dbf148bb
commit
993b471777
17
fisher.fish
17
fisher.fish
|
@ -177,7 +177,7 @@ function _fisher_commit
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
echo (count $added_pkgs) (count $updated_pkgs) (count $removed_pkgs) (_fisher_now $elapsed) | _fisher_status_report >&2
|
_fisher_status (count $added_pkgs) (count $updated_pkgs) (count $removed_pkgs) (_fisher_now $elapsed) >&2
|
||||||
end
|
end
|
||||||
|
|
||||||
function _fisher_pkg_remove_all
|
function _fisher_pkg_remove_all
|
||||||
|
@ -391,20 +391,21 @@ function _fisher_fishfile_format -a pkgs
|
||||||
'
|
'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function _fisher_fishfile_load
|
function _fisher_fishfile_load
|
||||||
command awk -v FS=\# '!/^#/ && NF { print $1 }'
|
command awk -v FS=\# '!/^#/ && NF { print $1 }'
|
||||||
end
|
end
|
||||||
|
|
||||||
function _fisher_status_report
|
function _fisher_status -a added updated removed elapsed
|
||||||
command awk '
|
command awk -v ADDED=$added -v UPDATED=$updated -v REMOVED=$removed -v ELAPSED=$elapsed '
|
||||||
|
BEGIN {
|
||||||
|
if (ADDED = ADDED - UPDATED) res = msg(res, "added", ADDED)
|
||||||
|
if (UPDATED) res = msg(res, "updated", UPDATED)
|
||||||
|
if (REMOVED = REMOVED - UPDATED) res = msg(res, "removed", REMOVED)
|
||||||
|
printf((res ? res : "done") " in %.2fs\n", ELAPSED / 1000)
|
||||||
|
}
|
||||||
function msg(res, str, n) {
|
function msg(res, str, n) {
|
||||||
return (res ? res ", " : "") str " " n " package" (n > 1 ? "s" : "")
|
return (res ? res ", " : "") str " " n " package" (n > 1 ? "s" : "")
|
||||||
}
|
}
|
||||||
$1 = $1 - $2 { res = msg(res, "added", $1) }
|
|
||||||
$2 { res = msg(res, "updated", $2) }
|
|
||||||
$3 = $3 - $2 { res = msg(res, "removed", $3) }
|
|
||||||
{ printf((res ? res : "done") " in %.2fs\n", ($4 / 1000)) }
|
|
||||||
'
|
'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue