Script for song management
Some checks failed
Build / build (push) Failing after 10m57s

[ci skip]
This commit is contained in:
Emil Miler 2024-05-30 09:11:15 +02:00
parent 9f162204eb
commit 00045ebab5
2 changed files with 76 additions and 0 deletions

54
manage Executable file
View File

@ -0,0 +1,54 @@
#!/bin/bash
SONGS_PATH="content/"
usage() {
cat <<EOF
Usage: $0 <command> [options]
Commands:
help Show this help message and exit
new <name> Create a new song with the specified name
Examples:
$0 help
$0 new [song-name]
EOF
exit 1
}
create_new_song() {
if [ -z "$name" ]; then
read -p "Song name (file-name-in-path): " name
fi
read -p "Song title: " title
read -p "Artist: " artist
read -p "Category: " category
mkdir -p "$SONGS_PATH/$name"
echo -e "{title: $title}\n{artist: $artist}" > "$SONGS_PATH/$name/$name.cho"
echo -e "+++\ntitle = \"$title\"\n[taxonomies]\ncategory = [\"$category\"]\nartist = [\"$artist\"]\n+++" > "$SONGS_PATH/$name/index.md"
echo "Song $name created."
}
if [ "$#" -lt 1 ]; then
usage
fi
case "$1" in
new)
if [ "$#" -eq 2 ]; then
name="$2"
fi
create_new_song
;;
help)
usage
;;
*)
echo -e "Invalid argument: $1\n"
usage
;;
esac

View File

@ -33,3 +33,25 @@ zola build
``` ```
This is done by default during the deploy pipeline. This is done by default during the deploy pipeline.
## Song management
The `manage` shell script lets you do basic song management and saves you some
manual labour. Simply run the script itself or invoke `help` to get a list of
all available commands.
For now the script only supports creating new songs, which it does in an
interactive way by asking for important data and filling all needed templates.
```
./manage help
Usage: ./manage <command> [options]
Commands:
help Show this help message and exit
new <name> Create a new song with the specified name
Examples:
./manage help
./manage new [song-name]
```