Add depgraph command.

Visualize program dependencies with PNGs generated by dot.
This commit is contained in:
Érico Rolim 2020-06-24 03:43:47 -03:00
parent 8089adf276
commit a29a58b46e
1 changed files with 39 additions and 0 deletions

39
utils/.local/bin/depgraph Executable file
View File

@ -0,0 +1,39 @@
#!/bin/sh
set -eu
args=
package=
open_after=
print_help() {
cat << EOF
Usage: $0 [flags] package
Flags:
-o: open result in imv
-f, -g, -m: flags passed to xbps-dgraph
EOF
exit 1
}
while [ $# -gt 0 ]; do
case $1 in
-g|-f|-m) args="$args $1";;
-o) open_after=1;;
*) package="$1";;
esac
shift
done
if [ -z "$package" ]; then
print_help
fi
echo "Generating graph for $package"
if [ "$open_after" ]; then
xbps-dgraph $args $package | dot -Tpng | imv -
else
xbps-dgraph $args $package | dot -Tpng -o "${package}.png"
fi