#!/usr/bin/env execlineb
# SPDX-FileCopyrightText: Peter Pentchev <roam@ringlet.net>
# SPDX-License-Identifier: BSD-2-Clause

elgetopt "c:"
importas -D "cargo" default_cargo CARGO
importas -D $default_cargo CARGO ELGETOPT_c
backtick -E version {
  pipeline {
    $CARGO metadata --format-version 1
  }
  jq -r ".packages[] | select(.name == \"utf8-locale\") | .version"
}
if {
  $CARGO fmt --check
}
if {
  $CARGO fc build
}
if {
  $CARGO doc --no-deps --all-features
}
if {
  $CARGO fc nextest run
}
if {
  if {
    rm -rf target/package
  }
  if {
    $CARGO publish --dry-run
  }
  cd "target/package/utf8-locale-${version}"
  if {
    $CARGO test
  }
  cd "../u8loc-${version}"
  $CARGO --config "patch.\"crates-io\".\"utf8-locale\".path=\"../utf8-locale-${version}\"" test
}
if {
  rust/tools/el-run-clippy -c $CARGO -n
}
echo "Seems fine for ${version}"
