Skip to content

Commit 35b4d9f

Browse files
committed
print usage information on invalid command
1 parent bf9f264 commit 35b4d9f

File tree

1 file changed

+37
-31
lines changed

1 file changed

+37
-31
lines changed

miri

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,38 @@
11
#!/bin/sh
2-
## Usage
3-
#
4-
# COMMANDS
5-
#
6-
# ./miri install <flags>:
7-
# Installs the miri driver and cargo-miri. <flags> are passed to `cargo
8-
# install`. Sets up the rpath such that the installed binary should work in any
9-
# working directory.
10-
#
11-
# ./miri build <flags>:
12-
# Just build miri. <flags> are passed to `cargo build`.
13-
#
14-
# ./miri test <flags>:
15-
# Build miri, set up a sysroot and then run the test suite. <flags> are passed
16-
# to the final `cargo test` invocation.
17-
#
18-
# ./miri run <flags>:
19-
# Build miri, set up a sysroot and then run the driver with the given <flags>.
20-
#
21-
# All commands also exist in a "-debug" variant (e.g. "./miri run-debug
22-
# <flags>") which uses debug builds instead of release builds, for faster build
23-
# times and slower execution times.
24-
#
25-
# ENVIRONMENT VARIABLES
26-
#
27-
# MIRI_SYSROOT:
28-
# If already set, the "sysroot setup" step is skipped.
29-
#
30-
# CARGO_EXTRA_FLAGS:
31-
# Pass extra flags to all cargo invocations.
2+
set -e
3+
USAGE=$(cat <<"EOF"
4+
COMMANDS
5+
6+
./miri install <flags>:
7+
Installs the miri driver and cargo-miri. <flags> are passed to `cargo
8+
install`. Sets up the rpath such that the installed binary should work in any
9+
working directory.
10+
11+
./miri build <flags>:
12+
Just build miri. <flags> are passed to `cargo build`.
13+
14+
./miri test <flags>:
15+
Build miri, set up a sysroot and then run the test suite. <flags> are passed
16+
to the final `cargo test` invocation.
17+
18+
./miri run <flags>:
19+
Build miri, set up a sysroot and then run the driver with the given <flags>.
20+
21+
All commands also exist in a "-debug" variant (e.g. "./miri run-debug
22+
<flags>") which uses debug builds instead of release builds, for faster build
23+
times and slower execution times.
24+
25+
ENVIRONMENT VARIABLES
26+
27+
MIRI_SYSROOT:
28+
If already set, the "sysroot setup" step is skipped.
29+
30+
CARGO_EXTRA_FLAGS:
31+
Pass extra flags to all cargo invocations.
32+
EOF
33+
)
3234

3335
## Preparation
34-
set -e
3536
# I'd love to use `jq` for parsing the JSON properly, but macOS is totally underequipped for this kind of work.
3637
TARGET=$(rustc --print target-spec-json -Z unstable-options | grep llvm-target | cut -d '"' -f 4)
3738
SYSROOT=$(rustc --print sysroot)
@@ -135,4 +136,9 @@ run|run-debug)
135136
# Then run the actual command.
136137
exec cargo run $CARGO_BUILD_FLAGS "$@"
137138
;;
139+
*)
140+
echo "Unknown command: $COMMAND"
141+
echo
142+
echo "$USAGE"
143+
exit 1
138144
esac

0 commit comments

Comments
 (0)