69d0683a8cd3751178b2f7dc58126b50ed48e2ec

Author
Enrico Maria Crisostomo <enrico.m.crisostomo@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

feat(macports): add commands to get list of updated ports (#8698)

Diff

 1diff --git a/plugins/macports/README.md b/plugins/macports/README.md
 2index ded823f3ff554c6c67ea7ef4eee630894d20ec75..09bd42df22e2db524f13bcf0882ace078b2c217b 100644
 3--- a/plugins/macports/README.md
 4+++ b/plugins/macports/README.md
 5@@ -15,7 +15,33 @@ plugins=(... macports)
 6 |-------|------------------------------------|--------------------------------------------------------------|
 7 | pc    | `sudo port clean --all installed`  | Clean up intermediate installation files for installed ports |
 8 | pi    | `sudo port install`                | Install package given as argument                            |
 9+| pli   | `port livecheck installed`         | Check for updates for installed ports                        |
10+| plm   | `port-livecheck-maintainer`        | Check for updates of ports mainained by the specified users  |
11 | psu   | `sudo port selfupdate`             | Update ports tree with MacPorts repository                   |
12 | puni  | `sudo port uninstall inactive`     | Uninstall inactive ports                                     |
13 | puo   | `sudo port upgrade outdated`       | Upgrade ports with newer versions available                  |
14 | pup   | `psu && puo`                       | Update ports tree, then upgrade ports to newest versions     |
15+
16+## Commands
17+
18+### port-livecheck-maintainer
19+
20+```text
21+Usage:
22+  port-livecheck-maintainer
23+  port-livecheck-maintainer (maintainer)+
24+  port-livecheck-maintainer -h|--help
25+
26+Check
27+
28+Options:
29+  maintainer  maintainer id
30+  -h          print this help message and exit
31+```
32+
33+Checks whether updates are available for ports whose maintainer is the current
34+user, or any of a specified list of maintainer expressions.  The current user
35+maintainer id is retrieved as follows:
36+
37+* The value of the `MACPORTS_MAINTAINER` variable, if set and not null.
38+* The value of the `USER` variable.
39diff --git a/plugins/macports/macports.plugin.zsh b/plugins/macports/macports.plugin.zsh
40index d1fde30d446cf1fe8a4dd995dba5841abd531b84..d438057f9aee6166d06d8579dcf54afd780b1a78 100644
41--- a/plugins/macports/macports.plugin.zsh
42+++ b/plugins/macports/macports.plugin.zsh
43@@ -1,6 +1,44 @@
44 alias pc="sudo port clean --all installed"
45 alias pi="sudo port install"
46+alias pli="port livecheck installed"
47+alias plm="port-livecheck-maintainer"
48 alias psu="sudo port selfupdate"
49 alias puni="sudo port uninstall inactive"
50 alias puo="sudo port upgrade outdated"
51-alias pup="psu && puo"
52+alias pup="sudo port selfupdate && sudo port upgrade outdated"
53+
54+port-livecheck-maintainer() {
55+  (( ${+commands[port]} == 0 )) || {
56+    print -- "port: not found" >&2
57+    return 1
58+  }
59+
60+  local -a help_flag
61+  zparseopts -D -E h=help_flag -help=help_flag
62+
63+  (( ${#help_flag} )) && {
64+    cat << EOF >&2
65+Usage:
66+  port-livecheck-maintainer
67+  port-livecheck-maintainer (maintainer)+
68+  port-livecheck-maintainer -h|--help
69+
70+Check
71+
72+Options:
73+  maintainer  maintainer id
74+  -h          print this help message and exit
75+EOF
76+    return 1
77+  }
78+
79+  if (( $# == 0 )); then
80+    local default=${MACPORTS_MAINTAINER:-${USER}}
81+    port livecheck maintainer:${default}
82+    return $?
83+  fi
84+
85+  for i in $@; do
86+    port livecheck maintainer:${i}
87+  done
88+}