38 lines
842 B
Plaintext
Executable File
38 lines
842 B
Plaintext
Executable File
#!/usr/bin/env nix-shell
|
|
#!nix-shell -i bash -p feeds.update-feed -p gnused
|
|
|
|
source=
|
|
passthruArgs=()
|
|
for arg in "$@"; do
|
|
case $arg in
|
|
(--*)
|
|
passthruArgs+=("$arg")
|
|
;;
|
|
(*)
|
|
if [ -z "$source" ]; then
|
|
source="$arg"
|
|
else
|
|
passthruArgs+=("$arg")
|
|
fi
|
|
esac
|
|
done
|
|
|
|
sources_dir=modules/data/feeds/sources
|
|
# prettify the URL, by default
|
|
name=$( \
|
|
echo "$source" \
|
|
| sed 's|^https://||' \
|
|
| sed 's|^http://||' \
|
|
| sed 's|^www\.||' \
|
|
| sed 's|/+$||' \
|
|
)
|
|
json_path="$sources_dir/$name/default.json"
|
|
|
|
# the name could have slashes in it, so we want to mkdir -p that
|
|
# but in a way where the least could go wrong.
|
|
pushd "$sources_dir"; mkdir -p "$name"; popd
|
|
|
|
# update.py: from `feeds.update-feed` (TODO: rename the binary!)
|
|
update.py "$name" "$json_path" "${passthruArgs[@]}"
|
|
cat "$json_path"
|