Skip to content

Commit 36224c2

Browse files
[DDW-957] Address PR feedback - rename arg2nz to more meaningful name
1 parent 1ca4033 commit 36224c2

File tree

2 files changed

+32
-31
lines changed

2 files changed

+32
-31
lines changed

scripts/build-installer-unix.sh

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,6 @@ source "$(dirname "$0")/utils.sh"
99

1010
CLUSTERS="$(xargs echo -n < "$(dirname "$0")"/../installer-clusters.cfg)"
1111

12-
usage() {
13-
test -z "$1" || { echo "ERROR: $*" >&2; echo >&2; }
14-
cat >&2 <<EOF
15-
Usage:
16-
$0 OPTIONS*
17-
18-
Build a Daedalus installer.
19-
20-
Options:
21-
--clusters "[CLUSTER-NAME...]"
22-
Build installers for CLUSTERS. Defaults to "mainnet staging testnet"
23-
--fast-impure Fast, impure, incremental build
24-
--build-id BUILD-NO Identifier of the build; defaults to '0'
25-
26-
--nix-path NIX-PATH NIX_PATH value
27-
28-
--upload-s3 Upload the installer to S3
29-
--test-installer Test the installer for installability
30-
31-
--verbose Verbose operation
32-
--quiet Disable verbose operation
33-
34-
EOF
35-
test -z "$1" || exit 1
36-
}
37-
38-
3912
###
4013
### Argument processing
4114
###
@@ -64,8 +37,8 @@ while test $# -ge 1
6437
do case "$1" in
6538
--clusters ) CLUSTERS="$2"; shift;;
6639
--fast-impure ) export fast_impure=true;;
67-
--build-id ) arg2nz "build identifier" "$2"; build_id="$2"; shift;;
68-
--nix-path ) arg2nz "NIX_PATH value" "$2";
40+
--build-id ) validate_arguments "build identifier" "$2"; build_id="$2"; shift;;
41+
--nix-path ) validate_arguments "NIX_PATH value" "$2";
6942
export NIX_PATH="$2"; shift;;
7043
--test-installer ) test_installer="--test-installer";;
7144

scripts/utils.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,41 @@
11
#!/usr/bin/env bash
22

3-
arg2nz() { test $# -ge 2 -a ! -z "$2" || usage "empty value for" "$1"; }
3+
usage() {
4+
test -z "$1" || { echo "ERROR: $*" >&2; echo >&2; }
5+
cat >&2 <<EOF
6+
Usage:
7+
$0 OPTIONS*
8+
9+
Build a Daedalus installer.
10+
11+
Options:
12+
--clusters "[CLUSTER-NAME...]"
13+
Build installers for CLUSTERS. Defaults to "mainnet staging testnet"
14+
--fast-impure Fast, impure, incremental build
15+
--build-id BUILD-NO Identifier of the build; defaults to '0'
16+
17+
--nix-path NIX-PATH NIX_PATH value
18+
19+
--upload-s3 Upload the installer to S3
20+
--test-installer Test the installer for installability
21+
22+
--verbose Verbose operation
23+
--quiet Disable verbose operation
24+
25+
EOF
26+
test -z "$1" || exit 1
27+
}
28+
29+
validate_arguments() { test $# -ge 2 -a ! -z "$2" || usage "empty value for" "$1"; }
30+
431
fail() {
532
echo "ERROR: $*" >&2
633
exit 1
734
}
35+
836
retry() {
937
local tries=$1
10-
arg2nz "iteration count" "$1"
38+
validate_arguments "iteration count" "$1"
1139
shift
1240
for i in $(seq 1 "${tries}"); do
1341
if "$@"; then

0 commit comments

Comments
 (0)