Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
cd ../../..

- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v5
with:
name: ${{ matrix.name }}
path: ${{ matrix.name }}.*
Expand All @@ -73,7 +73,7 @@ jobs:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
- uses: actions/download-artifact@v5
with:
path: artifacts

Expand Down
10 changes: 10 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,16 @@ fn run_exec(argv: &[String], dir: &Path, extra_args: &[OsString]) -> ! {
fn main() {
let args: Vec<OsString> = env::args_os().skip(1).collect();

// `--version` works anywhere, even outside a project, so handle it before
// looking for tasks.
if matches!(
args.first().and_then(|a| a.to_str()),
Some("--version" | "-V")
) {
println!("nr {}", env!("CARGO_PKG_VERSION"));
return;
}

let detection = match sources::detect() {
Some(d) => d,
None => {
Expand Down
11 changes: 11 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,17 @@ else
echo "(skipping uv equivalence test: uv not installed)"
fi

# Test 24: --version / -V print the version, and work outside a project
VER_TMP=$(mktemp -d)
OUTPUT=$(cd "$VER_TMP" && "$BIN_ABS" --version 2>&1)
OUTPUT_SHORT=$(cd "$VER_TMP" && "$BIN_ABS" -V 2>&1)
rmdir "$VER_TMP"
if echo "$OUTPUT" | grep -qE '^nr [0-9]+\.[0-9]+\.[0-9]+' && [ "$OUTPUT" = "$OUTPUT_SHORT" ]; then
pass "--version prints version ($OUTPUT)"
else
fail "--version prints version: '$OUTPUT' / '$OUTPUT_SHORT'"
fi

echo ""
echo "Results: ${PASS} passed, ${FAIL} failed"

Expand Down