2022-02-27 21:58:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2023-03-08 15:42:00 +00:00
|
|
|
error() {
|
|
|
|
echo "[ERROR]: $1"
|
|
|
|
exit 1
|
2022-02-27 21:58:28 +00:00
|
|
|
}
|
|
|
|
|
2023-03-08 15:42:00 +00:00
|
|
|
starship_version() {
|
2022-02-27 21:58:28 +00:00
|
|
|
starship_program_file="$1"
|
|
|
|
# Check if this is a relative path: if so, prepend './' to it
|
|
|
|
if [ "$1" = "${1#/}" ]; then
|
|
|
|
starship_program_file="./$starship_program_file"
|
|
|
|
fi
|
2023-03-08 15:42:00 +00:00
|
|
|
if "$starship_program_file" -V 2>&1 >/dev/null; then
|
2022-02-27 21:58:28 +00:00
|
|
|
"$starship_program_file" -V | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+'
|
|
|
|
else
|
|
|
|
# try to get this information from Cargo.toml
|
|
|
|
pushd "$(git rev-parse --show-toplevel)" || true
|
|
|
|
grep '^version = \"\(.*\)\"' Cargo.toml | cut -f 2 -d '"'
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
}
|