~riderius/riderius-cogs

ref: 62998d4fae15254fb054a16ec1021a87eb953d10 riderius-cogs/newcog.sh -rwxr-xr-x 1.4 KiB
62998d4friderius newcog.sh: add message if cog name missing 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/bash
# set -euo pipefail

if [ -z "$1" ]; then
    echo "USAGE: ./newcog [name of new cog]"
    exit 1
fi

NAME=$1
LOWERCASE_NAME=`echo $1 | tr '[:upper:]' '[:lower:]'`

mkdir $NAME

#__init__.py
echo "from .$LOWERCASE_NAME import $NAME" >> $NAME/__init__.py
echo "" >> $NAME/__init__.py
echo "" >> $NAME/__init__.py
echo "def setup(bot):" >> $NAME/__init__.py
echo "    bot.add_cog($NAME(bot))" >> $NAME/__init__.py

#info.json
echo "{" >> $NAME/info.json
echo "    \"author\" : "[\"riderius\"]", " >> $NAME/info.json
echo "    \"install_msg\" : \"\", " >> $NAME/info.json
echo "    \"name\" : \"$NAME\", " >> $NAME/info.json
echo "    \"short\" : \"\", " >> $NAME/info.json
echo "    \"description\" : \"\", " >> $NAME/info.json
echo "}" >> $NAME/info.json
sed 's/[ \t]\+$//' $NAME/info.json > /tmp/info.json.new
cat /tmp/info.json.new > $NAME/info.json

#LOWERCASE_NAME.py
echo "from redbot.core import commands" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "class $NAME(commands.Cog):" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "    def __init__(self, bot):" >> $NAME/$LOWERCASE_NAME.py
echo "      self.bot = bot" >> $NAME/$LOWERCASE_NAME.py
echo "" >> $NAME/$LOWERCASE_NAME.py
echo "  @commands.command()" >> $NAME/$LOWERCASE_NAME.py
echo "  async def $LOWERCASE_NAME(self, ctx):" >> $NAME/$LOWERCASE_NAME.py
echo "      \"\"\"\"\"\"" >> $NAME/$LOWERCASE_NAME.py