diff options
Diffstat (limited to 'bin/init_rust.sh')
-rwxr-xr-x | bin/init_rust.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bin/init_rust.sh b/bin/init_rust.sh new file mode 100755 index 0000000..38825b1 --- /dev/null +++ b/bin/init_rust.sh @@ -0,0 +1,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 |