11#! /usr/bin/env bash
22set -eo pipefail
33
4+ # NOTE: if you make modifications to this script, please increment the version number.
5+ # Major / minor: incremented for each stable release of Foundry.
6+ # Patch: incremented for each change between stable releases.
7+ FOUNDRYUP_INSTALLER_VERSION=" 0.3.0"
8+
49BASE_DIR=${XDG_CONFIG_HOME:- $HOME }
510FOUNDRY_DIR=${FOUNDRY_DIR:- " $BASE_DIR /.foundry" }
611FOUNDRY_VERSIONS_DIR=" $FOUNDRY_DIR /versions"
@@ -23,6 +28,8 @@ main() {
2328 case $1 in
2429 --) shift ; break ;;
2530
31+ -v|--version) shift ; version;;
32+ -U|--update) shift ; update;;
2633 -r|--repo) shift ; FOUNDRYUP_REPO=$1 ;;
2734 -b|--branch) shift ; FOUNDRYUP_BRANCH=$1 ;;
2835 -i|--install) shift ; FOUNDRYUP_VERSION=$1 ;;
@@ -32,7 +39,6 @@ main() {
3239 -P|--pr) shift ; FOUNDRYUP_PR=$1 ;;
3340 -C|--commit) shift ; FOUNDRYUP_COMMIT=$1 ;;
3441 -j|--jobs) shift ; FOUNDRYUP_JOBS=$1 ;;
35- -U|--update) shift ; update;;
3642 --arch) shift ; FOUNDRYUP_ARCH=$1 ;;
3743 --platform) shift ; FOUNDRYUP_PLATFORM=$1 ;;
3844 -h|--help)
@@ -71,7 +77,7 @@ main() {
7177
7278 # Ignore branches/versions as we do not want to modify local git state
7379 if [ -n " $FOUNDRYUP_REPO " ] || [ -n " $FOUNDRYUP_BRANCH " ] || [ -n " $FOUNDRYUP_VERSION " ]; then
74- warn " --branch, --version , and --repo arguments are ignored during local install"
80+ warn " --branch, --install, --use , and --repo arguments are ignored during local install"
7581 fi
7682
7783 # Enter local repo and build
@@ -256,6 +262,8 @@ USAGE:
256262
257263OPTIONS:
258264 -h, --help Print help information
265+ -v, --version Print the version of foundryup
266+ -U, --update Update foundryup to the latest version
259267 -i, --install Install a specific version from built binaries
260268 -l, --list List versions installed from built binaries
261269 -u, --use Use a specific installed version from built binaries
@@ -265,12 +273,31 @@ OPTIONS:
265273 -r, --repo Build and install from a remote GitHub repo (uses default branch if no other options are set)
266274 -p, --path Build and install a local repository
267275 -j, --jobs Number of CPUs to use for building Foundry (default: all CPUs)
268- -U, --update Update foundryup to the latest version
269276 --arch Install a specific architecture (supports amd64 and arm64)
270277 --platform Install a specific platform (supports win32, linux, and darwin)
271278EOF
272279}
273280
281+ version () {
282+ say " $FOUNDRYUP_INSTALLER_VERSION "
283+ exit 0
284+ }
285+
286+ update () {
287+ say " updating foundryup..."
288+
289+ # Download to a temporary file first
290+ tmp_file=" $( mktemp) "
291+ ensure download " $FOUNDRY_BIN_URL " " $tmp_file "
292+
293+ # Replace the current foundryup with the downloaded file
294+ ensure mv " $tmp_file " " $FOUNDRY_BIN_PATH "
295+ ensure chmod +x " $FOUNDRY_BIN_PATH "
296+
297+ say " successfully updated foundryup"
298+ exit 0
299+ }
300+
274301list () {
275302 if [ -d " $FOUNDRY_VERSIONS_DIR " ]; then
276303 for VERSION in $FOUNDRY_VERSIONS_DIR /* ; do
@@ -309,21 +336,6 @@ use() {
309336 fi
310337}
311338
312- update () {
313- say " updating foundryup..."
314-
315- # Download to a temporary file first
316- tmp_file=" $( mktemp) "
317- ensure download " $FOUNDRY_BIN_URL " " $tmp_file "
318-
319- # Replace the current foundryup with the downloaded file
320- ensure mv " $tmp_file " " $FOUNDRY_BIN_PATH "
321- ensure chmod +x " $FOUNDRY_BIN_PATH "
322-
323- say " successfully updated foundryup"
324- exit 0
325- }
326-
327339say () {
328340 printf " foundryup: %s\n" " $1 "
329341}
0 commit comments