add func cargo-init

This commit is contained in:
thek4n 2026-03-01 17:49:35 +03:00
parent 845f83c3e0
commit 06e80254bd

View File

@ -62,16 +62,13 @@ top-commands() {
}' | sort | uniq -c | sort -nr | sed 's/^[[:space:]]*//'
}
ci() {
# Create cargo project (cargo init)
cargo-init() {
if [[ -v 1 ]]; then
cargo init "${1}" && cd "${1}"
cargo init "${1}" && cd "${1}" && \
return "${?}"
fi
local -r mktemp_template='thek4n-rust-XXXXXX'
local temp
temp="$(mktemp -dt "${mktemp_template}")" && \
cd "${temp}" && \
cargo init .
local -r temp="/tmp/thek4n-rust-${RANDOM}"
mkdir "${temp}" && cd "${temp}" && cargo init . && \
return "${?}"
}