Skip to content

Commit 36307aa

Browse files
committed
Adding argument handling with shift example script
1 parent daf6bd9 commit 36307aa

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

basic/shift_args.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
set -u
4+
5+
dryrun=false
6+
7+
function usage() {
8+
echo "Usage: `basename $0` -p [project_name] -v [npm_version] --preid [prerelease_id] --dry-run"
9+
}
10+
11+
if [ $# == 0 ]; then
12+
usage
13+
fi
14+
15+
while [[ $# -gt 0 ]]
16+
do
17+
case $1 in
18+
-p | --project )
19+
shift
20+
project=$1
21+
;;
22+
-v | --version )
23+
shift
24+
version=$1
25+
;;
26+
--preid )
27+
shift
28+
preid=$1
29+
;;
30+
--dry-run )
31+
dryrun=true
32+
;;
33+
-h | --help )
34+
usage
35+
exit
36+
;;
37+
* )
38+
usage
39+
exit 1
40+
esac
41+
shift
42+
done
43+
44+
echo "Project: $project"
45+
echo "Version: $version"
46+
echo "Prerelease ID: $preid"
47+
echo "dry run: $dryrun"
48+
49+
result=$(cd projects/storefrontstyles && npm publish .)
50+
echo $result

0 commit comments

Comments
 (0)