Skip to content

Commit

Permalink
Merge pull request #177 from vulncheck-oss/install-specify-version
Browse files Browse the repository at this point in the history
🚧 playing with a version parameter
  • Loading branch information
acidjazz authored Dec 11, 2024
2 parents 307f4cb + c769dc8 commit e4c193b
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
#!/bin/bash

# Fetch the latest version from GitHub
echo "Fetching latest version..."
VERSION=$(curl -s https://api.github.com/repos/vulncheck-oss/cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/v//')
# Parse command line arguments
for arg in "$@"
do
case $arg in
--version=*)
SPECIFIED_VERSION="${arg#*=}"
shift # Remove --version= from processing
;;
esac
done

if [ -n "$SPECIFIED_VERSION" ]; then
VERSION="$SPECIFIED_VERSION"
echo "Using specified version: $VERSION"
else
# Fetch the latest version from GitHub
echo "Fetching latest version..."
VERSION=$(curl -s https://api.github.com/repos/vulncheck-oss/cli/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/v//')

if [ -z "$VERSION" ]; then
echo "Failed to fetch the latest version."
exit 1
fi
if [ -z "$VERSION" ]; then
echo "Failed to fetch the latest version. Please check your internet connection and try again."
exit 1
fi

echo "Latest version: $VERSION"
echo "Latest version: $VERSION"
fi

# Detect the operating system and architecture
if [[ "$OSTYPE" == "darwin"* ]]; then
Expand Down

0 comments on commit e4c193b

Please sign in to comment.