#!/usr/bin/env bash
# shellcheck disable=SC1091,SC2016

source "$SHELLOPS_DIR/plugins/tools/common.sh"
import "$SHELLOPS_DIR/lib/rust/api.sh"

rust_source_cargo_env

if command -v rustup >/dev/null 2>&1; then
  shell_rc_offer_line \
    "Rust's cargo environment" \
    'source "$HOME/.cargo/env"'
  return 0
fi

version="$(__shellops__tool_version rustup)"

rust_install_rustup "$version" -y --no-modify-path

shell_rc_offer_line \
  "Rust's cargo environment" \
  'source "$HOME/.cargo/env"'
