summaryrefslogtreecommitdiff
path: root/bin/init_rust.sh
blob: 5388a691b573705b1ca8d4d02a026964f2984529 (plain)
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
#!/bin/sh -e

YEAR=${YEAR:-$(date +%Y)}
DAY=${DAY:-$(TZ=EST date '+%d')}

GIT_USER=$(git config --get 'user.name')
GIT_EMAIL=$(git config --get 'user.email')

CARGO=$( sed "s/^#\(.*${DAY}\)/\1/" <"${YEAR}/rust/Cargo.toml")
echo "${CARGO}" >"${YEAR}/rust/Cargo.toml"

cd "${YEAR}/rust"
mkdir "day${DAY}" || :
cd "day${DAY}"

cargo init --bin

cat > 'Cargo.toml' << END_OF_TOML
[package]
name = "day${DAY}"
version = "0.1.0"
authors = ["${GIT_USER} <${GIT_EMAIL}>"]
edition = "2018"

[dependencies]
END_OF_TOML