add script for creating template
This commit is contained in:
parent
ed8cd12d25
commit
f9ddad5f88
1 changed files with 21 additions and 0 deletions
21
create.sh
Executable file
21
create.sh
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
num=$1
|
||||
|
||||
echo "$num" | grep -q "^[1-9][0-9]\{,4\}$" || {
|
||||
echo "Err: no valid number given" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
parent=$((num / 100))
|
||||
pdir="solutions/${parent}/q${num}"
|
||||
sol_file="${pdir}/solution.go"
|
||||
|
||||
if [ -f "$sol_file" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Creating template for question No. $num" >&2
|
||||
mkdir -pv "$pdir"
|
||||
echo "package q$num" > "$sol_file"
|
||||
echo "Created $sol_file"
|
||||
Loading…
Add table
Add a link
Reference in a new issue