Skip to content

Commit

Permalink
Add --list argument
Browse files Browse the repository at this point in the history
  • Loading branch information
asherikov committed Nov 29, 2024
1 parent 87536b3 commit 00c22f1
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 25 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ test_update:
! ${WSHANDLER} -t ${TYPE} -r ./ is_source_space
${WSHANDLER} -t ${TYPE} -r tests/update/ unshallow staticoma
${WSHANDLER} -t ${TYPE} --root tests/update/ status
${WSHANDLER} -t ${TYPE} --root tests/update/ -l .${TYPE} status
${WSHANDLER} -t ${TYPE} --list tests/update/.${TYPE} status
${WSHANDLER} -t ${TYPE} --root tests/update/ -j 2 clean
${WSHANDLER} -t ${TYPE} -r tests/update/ --jobs 2 --policy shallow,rebase,nolfs update
${WSHANDLER} -t ${TYPE} --root tests/update/ status
Expand Down
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,29 @@ Usage
```
Usage (default values are shown in curly braces):
wshandler [<COMMON_ARGS>] [<COMMAND_ARGS>] <COMMAND> <COMMAND_ARGS>
Notation:
<REQUIRED ARGUMENT>
{DEFAULT VALUE}
[OPTIONAL ARGUMENT]
(VALID OPTIONS IN A LIST)
Common arguments:
-y|--yq <YQ_BINARY> {yq}
-r|--root <WORKSPACE_ROOT> {./}
-c|--cache <CACHE_DIR> {<WORKSPACE_ROOT>}
-t|--type rosinstall|repos {repos}
-i|--indent 1|2|3... {4}
-k|--keep-going {false}
-y|--yq <YQ_BINARY> {yq} # override yq path
-r|--root <WORKSPACE_ROOT> {./} # parent of --list if it is a path
-c|--cache <CACHE_DIR> {<WORKSPACE_ROOT>} # temporary files created here
-t|--type rosinstall|repos {repos} # repository list format
-i|--indent 1|2|3... {4} # default indentation in yaml repository list
-k|--keep-going {false} # do not stop on errors
-l|--list <FILENAME> {.rosinstall|.repos} # default depends on --type
List commands:
Information:
status
is_source_space
Initialization:
[-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] clone git <LIST_REPOSITORY> [<BRANCH>]
[-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] init [git <PACKAGE_REPOSITORY> ...]
[-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs)] clone git <LIST_REPOSITORY> [<BRANCH>]
[-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs)] init [git <PACKAGE_REPOSITORY> ...]
Modification:
[-p|--policy {ask}|add|show] scrape
add git <PACKAGE_NAME> <PACKAGE_URL> <PACKAGE_VERSION>
Expand All @@ -56,9 +65,10 @@ List commands:
remove <PACKAGE_NAME>
remove_by_url <PACKAGE_URL>
[-p|--policy {keep}|replace] merge <LIST_FILENAME>
Package repository commands:
Global:
[-j|--jobs <NUM_THREADS> {1}] [-p|--policy policy1[,policy2] ({default}|shallow|nolfs|rebase)] update
[-j|--jobs <NUM_THREADS> {1}] [-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs|rebase)] update
[-j|--jobs <NUM_THREADS> {1}] clean
[-j|--jobs <NUM_THREADS> {1}] [-s|-source {git}] foreach '<COMMAND>'
prune
Expand All @@ -71,6 +81,7 @@ Package repository commands:
commit '<MESSAGE>'
Local:
unshallow <PACKAGE_NAME>
wshandler installation commands:
install_test_deps
[-p|--policy {skip_yq}|snap|download] install <BIN_PATH {~/bin}>
Expand Down
60 changes: 44 additions & 16 deletions wshandler
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,29 @@ help()
EXIT_CODE=${1:-"0"}
echo "Usage (default values are shown in curly braces):"
echo " wshandler [<COMMON_ARGS>] [<COMMAND_ARGS>] <COMMAND> <COMMAND_ARGS>"
echo ""
echo "Notation:"
echo " <REQUIRED ARGUMENT>"
echo " {DEFAULT VALUE}"
echo " [OPTIONAL ARGUMENT]"
echo " (VALID OPTIONS IN A LIST)"
echo ""
echo "Common arguments:"
echo " -y|--yq <YQ_BINARY> {yq}"
echo " -r|--root <WORKSPACE_ROOT> {./}"
echo " -c|--cache <CACHE_DIR> {<WORKSPACE_ROOT>}"
echo " -t|--type rosinstall|repos {repos}"
echo " -i|--indent 1|2|3... {4}"
echo " -k|--keep-going {false}"

echo " -y|--yq <YQ_BINARY> {yq} # override yq path"
echo " -r|--root <WORKSPACE_ROOT> {./} # parent of --list if it is a path"
echo " -c|--cache <CACHE_DIR> {<WORKSPACE_ROOT>} # temporary files created here"
echo " -t|--type rosinstall|repos {repos} # repository list format"
echo " -i|--indent 1|2|3... {4} # default indentation in yaml repository list"
echo " -k|--keep-going {false} # do not stop on errors"
echo " -l|--list <FILENAME> {.rosinstall|.repos} # default depends on --type"
echo ""
echo "List commands:"
echo " Information:"
echo " status"
echo " is_source_space"
echo " Initialization:"
echo " [-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] clone git <LIST_REPOSITORY> [<BRANCH>]"
echo " [-p|--policy policy1[,policy2] ({default}|shallow|nolfs)] init [git <PACKAGE_REPOSITORY> ...]"
echo " [-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs)] clone git <LIST_REPOSITORY> [<BRANCH>]"
echo " [-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs)] init [git <PACKAGE_REPOSITORY> ...]"
echo " Modification:"
echo " [-p|--policy {ask}|add|show] scrape"
echo " add git <PACKAGE_NAME> <PACKAGE_URL> <PACKAGE_VERSION>"
Expand All @@ -34,10 +42,10 @@ help()
echo " remove <PACKAGE_NAME>"
echo " remove_by_url <PACKAGE_URL>"
echo " [-p|--policy {keep}|replace] merge <LIST_FILENAME>"

echo ""
echo "Package repository commands:"
echo " Global:"
echo " [-j|--jobs <NUM_THREADS> {1}] [-p|--policy policy1[,policy2] ({default}|shallow|nolfs|rebase)] update"
echo " [-j|--jobs <NUM_THREADS> {1}] [-p|--policy <POLICY1[,POLICY2]> ({default}|shallow|nolfs|rebase)] update"
echo " [-j|--jobs <NUM_THREADS> {1}] clean"
echo " [-j|--jobs <NUM_THREADS> {1}] [-s|-source {git}] foreach '<COMMAND>'"
echo " prune"
Expand All @@ -50,7 +58,7 @@ help()
echo " commit '<MESSAGE>'"
echo " Local:"
echo " unshallow <PACKAGE_NAME>"

echo ""
echo "wshandler installation commands:"
echo " install_test_deps"
echo " [-p|--policy {skip_yq}|snap|download] install <BIN_PATH {~/bin}>"
Expand Down Expand Up @@ -398,12 +406,27 @@ check_workspace()
fi
WSH_YQ=("${WSH_YQ_BINARY}" --indent "${WSH_INDENT}")

WSH_WORKSPACE_ROOT=${WSH_WORKSPACE_ROOT:-"./"}
test -d "${WSH_WORKSPACE_ROOT}" || (echo "'${WSH_WORKSPACE_ROOT}' does not exist" && false)
WSH_WORKSPACE_ROOT="$(realpath "${WSH_WORKSPACE_ROOT}")/"

WSH_WORKSPACE_TYPE=${WSH_WORKSPACE_TYPE:-"repos"}
WSH_REPOLIST="${WSH_WORKSPACE_ROOT}/.${WSH_WORKSPACE_TYPE}"
if [ -n "${WSH_REPOLIST}" ] && [ -f "${WSH_REPOLIST}" ]
then
WSH_WORKSPACE_ROOT=$(realpath $(dirname "${WSH_REPOLIST}"))
WSH_REPOLIST=$(realpath "${WSH_REPOLIST}")
else
WSH_WORKSPACE_ROOT=${WSH_WORKSPACE_ROOT:-"./"}
WSH_WORKSPACE_ROOT="$(realpath "${WSH_WORKSPACE_ROOT}")/"

if [ -n "${WSH_REPOLIST}" ]
then
WSH_REPOLIST="${WSH_WORKSPACE_ROOT}/${WSH_REPOLIST}"
else
WSH_REPOLIST="${WSH_WORKSPACE_ROOT}/.${WSH_WORKSPACE_TYPE}"
fi
fi

test -d "${WSH_WORKSPACE_ROOT}" || (echo "'${WSH_WORKSPACE_ROOT}' does not exist" && false)
test -f "${WSH_REPOLIST}" || (echo "'${WSH_REPOLIST}' does not exist" && false)

WSH_CACHE_DIR=${WSH_CACHE_DIR:-"${WSH_WORKSPACE_ROOT}/.wshandler"}

if [ ! -f "${WSH_REPOLIST}" ]
Expand Down Expand Up @@ -697,6 +720,7 @@ WSH_XARGS=(xargs --no-run-if-empty -L 1 -P "${WSH_JOBS}")
WSH_KEEP_GOING=""
WSH_YQ_BINARY="yq"
WSH_SOURCE_TYPE="git"
WSH_REPOLIST=

while [[ $# -gt 0 ]]
do
Expand Down Expand Up @@ -737,6 +761,10 @@ do
WSH_SOURCE_TYPE=$2
shift; shift;;

-l|--list)
WSH_REPOLIST=$2
shift; shift;;

clone|init)
"execute_$1" "${@:2}"
exit;;
Expand Down

0 comments on commit 00c22f1

Please sign in to comment.