Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src/lib/repo
diff options
context:
space:
mode:
authorChristian Heusel <christian@heusel.eu>2023-09-02 12:31:12 +0200
committerLevente Polyak <anthraxx@archlinux.org>2023-11-26 18:23:17 +0100
commit9a356eae828ce0e75d49e3efdb42bac089eb528a (patch)
tree5001c1bd9bff0e4cff2e10d31e9ab56242f9a537 /src/lib/repo
parentae14c246b800139e3a8f5589fb8fe12aaeab6a76 (diff)
feat(web): implement option to print the URL instead of opening it
In certain situations, users may encounter limitations when unable to utilize xdg-open (e.g., when connected to an Arch machine via SSH). Consequently, this commit introduces the option to simply print the repository link to copy or click on it. Signed-off-by: Christian Heusel <christian@heusel.eu> Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
Diffstat (limited to 'src/lib/repo')
-rw-r--r--src/lib/repo/web.sh23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/lib/repo/web.sh b/src/lib/repo/web.sh
index 45ea53b..ab3d8c7 100644
--- a/src/lib/repo/web.sh
+++ b/src/lib/repo/web.sh
@@ -23,6 +23,7 @@ pkgctl_repo_web_usage() {
no arguments, open the package cloned in the current working directory.
OPTIONS
+ --print Print the url instead of opening it with xdg-open
-h, --help Show this help text
EXAMPLES
@@ -32,7 +33,8 @@ _EOF_
pkgctl_repo_web() {
local pkgbases=()
- local path giturl pkgbase
+ local path giturl pkgbase url
+ local mode=open
# option checking
while (( $# )); do
@@ -41,6 +43,10 @@ pkgctl_repo_web() {
pkgctl_repo_web_usage
exit 0
;;
+ --print)
+ mode=print
+ shift
+ ;;
--)
shift
break
@@ -56,7 +62,7 @@ pkgctl_repo_web() {
done
# Check if web mode has xdg-open
- if ! command -v xdg-open &>/dev/null; then
+ if [[ ${mode} == open ]] && ! command -v xdg-open &>/dev/null; then
die "The web command requires 'xdg-open'"
fi
@@ -78,7 +84,18 @@ pkgctl_repo_web() {
fi
for pkgbase in "${pkgbases[@]}"; do
+ pkgbase=$(basename "${pkgbase}")
path=$(gitlab_project_name_to_path "${pkgbase}")
- xdg-open "${GIT_PACKAGING_URL_HTTPS}/${path}"
+ url="${GIT_PACKAGING_URL_HTTPS}/${path}"
+ case ${mode} in
+ open)
+ xdg-open "${url}"
+ ;;
+ print)
+ printf "%s\n" "${url}"
+ ;;
+ *)
+ die "Unknown mode: ${mode}"
+ esac
done
}