2018-11-11 08:19:04 -08:00
|
|
|
#!/usr/bin/env bash
|
2018-10-29 09:52:26 -07:00
|
|
|
#
|
2019-03-20 21:01:23 -07:00
|
|
|
# Outputs the current crate version from a given Cargo.toml
|
2018-10-29 09:52:26 -07:00
|
|
|
#
|
2018-11-11 09:25:59 -08:00
|
|
|
set -e
|
2018-10-29 09:52:26 -07:00
|
|
|
|
2019-03-20 21:01:23 -07:00
|
|
|
Cargo_toml=$1
|
|
|
|
[[ -n $Cargo_toml ]] || {
|
|
|
|
echo "Usage: $0 path/to/Cargo.toml"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
|
|
|
[[ -r $Cargo_toml ]] || {
|
|
|
|
echo "Error: unable to read $Cargo_toml"
|
|
|
|
exit 1
|
|
|
|
}
|
2018-10-29 09:52:26 -07:00
|
|
|
|
|
|
|
while read -r name equals value _; do
|
|
|
|
if [[ $name = version && $equals = = ]]; then
|
|
|
|
echo "${value//\"/}"
|
|
|
|
exit 0
|
|
|
|
fi
|
2019-03-20 21:01:23 -07:00
|
|
|
done < <(cat "$Cargo_toml")
|
2018-10-29 09:52:26 -07:00
|
|
|
|
|
|
|
echo Unable to locate version in Cargo.toml 1>&2
|
|
|
|
exit 1
|