[config] default_to_workspace = false [env] DEBUG = true RELEASE = false NO_X11 = false EXEC_PATH = "target/debug/cocmd" BUILD_ARCH = "current" [env.release] DEBUG = false RELEASE = true EXEC_PATH = "target/release/cocmd" # Helpers [tasks.update-cli-docs] script_runner = "@shell" script = ''' cargo run -- docs > ../cocmd-website/docs/cli-docs.md ''' [tasks.version-bump] script_runner = "@shell" script = ''' bump_version() { # Extract the current version from Cargo.toml current_version=$(grep '^version =' Cargo.toml | sed -E 's/[^0-9.]+//g') # Split the current version into major, minor, and patch parts IFS='.' read -ra version_parts <<< "$current_version" major="${version_parts[0]}" minor="${version_parts[1]}" patch="${version_parts[2]}" # Increment the patch version by 1 ((patch++)) # Update the version variable version="$major.$minor.$patch" } echo "Please enter a version number (x.y.z) or ENTER: " read version # If the user didn't provide an input, bump the version automatically if [ -z "$version" ]; then bump_version echo "Automatically bumped version to: $version" else # Validate the version number format (e.g., using regular expressions) if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then echo "Valid version number: $version" else echo "Invalid version number: $version" exit 1 fi fi # Update Cargo.toml with the chosen or bumped version sed "s/^version = .*/version = \"$version\"/" Cargo.toml > Cargo.toml.bak mv Cargo.toml.bak Cargo.toml # Update rust main.rs cli printout sed "s/version = .*,/version = \"$version\",/" src/main.rs > src/main.rs.bak mv src/main.rs.bak src/main.rs # Ask the user for confirmation before proceeding read -p "Do you want to GIT commit+tag+push with version $version? (y/n): " confirmation if [ "$confirmation" == "y" ]; then # Commit the change git add -A git commit -m "Bump version to $version" # Create a Git tag for the new version git tag -a "v$version" -m "v$version" git push --tags else echo "Not commited" fi ''' [tasks.test] command = "cargo" args = ["test", "--workspace", "--", "--nocapture"] [tasks.coverage-run] script_runner = "@shell" script = ''' grcov . -s . --binary-path ./target/debug/ -t html --branch --ignore-not-existing -o ./target/debug/coverage/ open ./target/debug/coverage/index.html '''