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>
This commit is contained in:
parent
ae14c246b8
commit
9a356eae82
|
@ -325,6 +325,7 @@ _pkgctl_repo_switch_opts() {
|
|||
|
||||
|
||||
_pkgctl_repo_web_args=(
|
||||
--print
|
||||
-h --help
|
||||
)
|
||||
_pkgctl_repo_web_opts() { _filedir -d; }
|
||||
|
|
|
@ -134,6 +134,7 @@ _pkgctl_repo_create_args=(
|
|||
)
|
||||
|
||||
_pkgctl_repo_web_args=(
|
||||
'--print[Print the url instead of opening it with xdg-open]'
|
||||
'(-h --help)'{-h,--help}'[Display usage]'
|
||||
'*:git_dir:_files -/'
|
||||
)
|
||||
|
|
|
@ -18,6 +18,9 @@ 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 a help text
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue