summaryrefslogtreecommitdiff
path: root/sync.sh
blob: 8d8b16734f486ddad01b2e9bb9dde8e306d1094f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/env bash

usage()
{
    echo "Usage: sync [-p]"
    echo "Repository syncing script."
    echo "  -p         Restore all NuGet packages for the repository"
    echo "If no option is specified, then \"sync.sh -p\" is implied."
    exit 1
}

working_tree_root="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
unprocessedBuildArgs=

# Parse arguments
# Assume the default '-p' argument if the only arguments specified are specified after double dash.
# Only position parameters can be specified after the double dash.
if [ $# == 0 ] || [ $1 == '--' ]; then
    buildArgs="-p"
fi

while [[ $# -gt 0 ]]
do
    opt="$1"
    case $opt in
        -h|--help)
        usage
        ;;
        -p)
        buildArgs="-p"
        ;;
        *)
        unprocessedBuildArgs="$unprocessedBuildArgs $1"
    esac
    shift
done

$working_tree_root/run.sh sync $buildArgs $unprocessedBuildArgs
if [ $? -ne 0 ]
then
    echo "ERROR: An error occurred while syncing packages; See $working_tree_root/sync.log for more details. There may have been networking problems, so please try again in a few minutes."
    exit 1
fi

echo "Sync completed successfully."
exit 0