Add things

This commit is contained in:
Case Duckworth 2020-04-15 00:26:04 +00:00
parent 1aa1496b0d
commit b57f68559c
2 changed files with 66 additions and 3 deletions

View File

@ -15,6 +15,11 @@ groupck()
exit 3
}
}
setperms()
{
chown :bakers "$1"
chmod a+r,g+w "$1"
}
usage()
{
@ -55,7 +60,7 @@ bread_news()
n) #shellcheck disable=2034
num="$OPTARG" ;;
s)
cmd="grep -R \"$OPTARG\" \"$BREADNEWS\" -l"
cmd="grep -R \"$OPTARG\" \"$BREADNEWS\" -l --exclude-dir .git"
;;
w)
groupck admin
@ -67,6 +72,7 @@ bread_news()
ENDOFARTICLE
$EDITOR "$article"
setperms admin
exit
;;
\?) return 2 ;;
@ -101,7 +107,7 @@ bread_docs()
exit
;;
s)
grep -R "$OPTARG" "$BREADDOCS" -l|while read -r doc; do
grep -R "$OPTARG" "$BREADDOCS" -l --exclude-dir .git|while read -r doc; do
echo " 🍞 🥖 🥐 "
printf '\033[34;1;4m%s\033[0m\n' "$(M title "$doc")"
printf '\033[34;1m%s\033[0m\n' "$(M date "$doc")"
@ -127,11 +133,12 @@ bread_docs()
else
cp "$doc" "$fname"
fi
setperms bakers
return
;;
e)
groupck bakers
matches=( $(grep -R "$OPTARG" "$BREADDOCS" -l) )
matches=( $(grep -R "$OPTARG" "$BREADDOCS" -l --exclude-dir .git) )
if [[ "${#matches[@]}" -eq 1 ]]; then
$EDITOR "${matches[0]}"
return
@ -141,6 +148,7 @@ bread_docs()
$EDITOR "$doc"
return
done
setperms bakers
;;
\?) return 2 ;;
*) return 2 ;;
@ -157,6 +165,13 @@ bread_docs()
echo " 🍞 🥖 🥐 "
}
bread_publish()
{
groupck admin
git -C /bread/site pull
make -C /bread/site publish
}
main()
{ # entry point
while getopts h opt; do
@ -169,6 +184,7 @@ main()
shift "$((OPTIND - 1))"
cmd="$1"; shift
[ -z "$cmd" ] && usage
bread_"$cmd" "$@" || exit $?
}

47
flour/bin/flour Executable file
View File

@ -0,0 +1,47 @@
#!/bin/bash
# flour: package management with extras
# by breadw
declare -a to_install
declare -a to_remove
declare -a to_upgrade
upgrade_all=false
usage()
{
case "$1" in
[0-9]*) ec="$1"; shift ;;
*) ec=0 ;;
esac
if [ "$#" -gt 0 ]; then
printf '!! flour: %s\n\n' "$*"
fi
sed -n '2,3s/#* *//p' "$0"
echo
cat <<-ENDUSAGE
usage: flour COMMAND [PACKAGE...]
COMMANDS:
-l list packages
-i PKG install PKG
-r PKG remove PKG
-u PKG update PKG
-U update all packages
ENDUSAGE
exit "$ec"
}
main()
{
while getopts hli:r:u:U opt; do
case "$opt" in
h) usage ;;
l) list && exit ;;
i) ;;
r) ;;
u) ;;
U) ;;
\?) usage 2 ;;
*) usage 2 ;;
esac
done
}