New usage

This commit is contained in:
Sahil Ahuja 2025-02-10 12:05:12 +05:30
parent 4205d67f5b
commit 3e5a503770

View File

@ -4,19 +4,20 @@
### Functions
usage()
{
echo "usage: $0 [-c cs-repo -v version] | [-h]"
echo "usage: $0 [-c cs-repo -v version -k kustomization_list] | [-h]"
}
main()
{
local CS_REPO_NAME=$1
local VERSION=$2
local CSLIST_PATH=$3 #"./.github/cslist.txt"
#Get list of repos from cslist.txt
# Example lines in file:
#cs-brx mat81-dev/brx/brx-2jitsi/kustomization.yaml cs-brx.git\/\/brx\/brx-2jitsi?ref=
#cs-brx mat81-dev/brx/brx-3main/kustomization.yaml cs-brx.git\/\/brx\/brx-3main?ref=
CSLIST_PATH="./.github/cslist.txt"
CSLIST=$(cat $CSLIST_PATH | grep ^$CS_REPO_NAME | tr -s " " | awk -v FS=' ' -v OFS='\t' '/^[^#]/' )
echo "$CSLIST" #doublequote preserves the shape of the input variable, including endlines
if [ -z "$CSLIST" ]
@ -46,6 +47,9 @@ while [ "$1" != "" ]; do
-v | --version ) shift
VERSION=$1
;;
-k | --kustomization_list ) shift
CSLIST_PATH=$1
;;
-h | --help ) usage
exit
;;
@ -55,11 +59,11 @@ while [ "$1" != "" ]; do
shift
done
if [[ -z $CS_REPO_NAME || -z $VERSION ]]
if [[ -z $CS_REPO_NAME || -z $VERSION || -z $CSLIST_PATH ]]
then
echo "Not enough arguments"
usage
exit
fi
main "$CS_REPO_NAME" "$VERSION"
main "$CS_REPO_NAME" "$VERSION" "$CSLIST_PATH"