Initial commit
This commit is contained in:
39
scripts/mkday
Executable file
39
scripts/mkday
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
|
||||
while getopts y:l:d: flag
|
||||
do
|
||||
case "${flag}" in
|
||||
y) year=${OPTARG};;
|
||||
l) language=${OPTARG};;
|
||||
d) day=${OPTARG};;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ ! $year || ! $language || ! $day ]]
|
||||
then
|
||||
echo "Invalid usage! Required flags are -y, -l and -d";
|
||||
echo "Bye...";
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
case $language in
|
||||
"ts") lang="typescript";;
|
||||
*) lang="unknown";;
|
||||
esac
|
||||
|
||||
cd $year
|
||||
|
||||
mkdir -p $lang/day$day
|
||||
|
||||
cp ../templates/$lang/* ./$lang/day$day
|
||||
|
||||
cd ./$lang/day$day
|
||||
|
||||
for f in d*.txt
|
||||
do
|
||||
if [[ "$f" =~ ^(d)XX(p[0-9]\.)txt$ ]]; then
|
||||
mv "$f" "${BASH_REMATCH[1]}${day}${BASH_REMATCH[2]}ts"
|
||||
fi
|
||||
done
|
||||
|
||||
mv "index.txt" "index.ts"
|
Reference in New Issue
Block a user