-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
executable file
·67 lines (57 loc) · 1.94 KB
/
script.sh
File metadata and controls
executable file
·67 lines (57 loc) · 1.94 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
get_templates () {
local -n arr=$1
# for key in "${!arr[@]}"; do
# echo "${key}" "${arr[${key}]}"
# done
directories_before=$(find . -maxdepth 1 -type d)
git clone "${arr["ssh_url"]}"
directories_after=$(find . -maxdepth 1 -type d)
cloned_directory=$(comm -13 <(echo "$directories_before") <(echo "$directories_after"))
echo "The repository was cloned into: $cloned_directory"
copied=$(ls "$cloned_directory")
mv "$cloned_directory/$copied" "${arr["filename"]}"
rm -rf "$cloned_directory"
}
declare -A pyproject_template
pyproject_template+=(["ssh_url"]="[email protected]:snippets/3736540.git" ["filename"]="pyproject.toml")
declare -A flake8_template
declare -A precommit_template
precommit_template+=(["ssh_url"]="[email protected]:snippets/3736547.git" ["filename"]=".pre-commit-config.yaml")
if [ $# -eq 0 ]; then
echo "No arguments provided, cloning all templates..."
get_templates pyproject_template
get_templates flake8_template
get_templates precommit_template
else
# Iterate over all provided arguments
for arg in "$@"; do
case $arg in
pyproject)
get_templates pyproject_template
;;
flake8)
get_templates flake8_template
;;
precommit)
get_templates precommit_template
;;
*)
echo "Unknown template: $arg"
echo "Available templates are:"
echo " - pyproject"
echo " - flake8"
echo " - precommit"
;;
esac
done
fi
mkdir src tests
touch src/main.py
touch tests/test_main.py
echo "import pytest
from src.main import hello
def test_print_statement(capfd):
hello()
out, err = capfd.readouterr()
assert \"x\" in out" > tests/test_main.py