Add legacy_args, fix the helper

This commit is contained in:
Kay0u 2020-03-30 21:32:29 +02:00
parent 51a0502e91
commit 90459e7ae6
No known key found for this signature in database
GPG key ID: AE1DCADB6415A156
2 changed files with 16 additions and 4 deletions

View file

@ -303,8 +303,6 @@ user:
arguments:
permission:
help: Name of the permission to fetch info about
extra:
pattern: *pattern_username
### user_permission_update()
update:

View file

@ -270,6 +270,8 @@ ynh_webpath_register () {
#
# Requires YunoHost version 3.7.0 or higher.
ynh_permission_create() {
# Declare an array to define the options of this helper.
local legacy_args=pua
declare -Ar args_array=( [p]=permission= [u]=url= [a]=allowed= )
local permission
local url
@ -298,6 +300,8 @@ ynh_permission_create() {
#
# Requires YunoHost version 3.7.0 or higher.
ynh_permission_delete() {
# Declare an array to define the options of this helper.
local legacy_args=p
declare -Ar args_array=( [p]=permission= )
local permission
ynh_handle_getopts_args "$@"
@ -312,6 +316,8 @@ ynh_permission_delete() {
#
# Requires YunoHost version 3.7.0 or higher.
ynh_permission_exists() {
# Declare an array to define the options of this helper.
local legacy_args=p
declare -Ar args_array=( [p]=permission= )
local permission
ynh_handle_getopts_args "$@"
@ -327,6 +333,8 @@ ynh_permission_exists() {
#
# Requires YunoHost version 3.7.0 or higher.
ynh_permission_url() {
# Declare an array to define the options of this helper.
local legacy_args=pu
declare -Ar args_array=([p]=permission= [u]=url=)
local permission
local url
@ -352,6 +360,8 @@ ynh_permission_url() {
# example: ynh_permission_update --permission admin --add samdoe --remove all_users
# Requires YunoHost version 3.7.0 or higher.
ynh_permission_update() {
# Declare an array to define the options of this helper.
local legacy_args=par
declare -Ar args_array=( [p]=permission= [a]=add= [r]=remove= )
local permission
local add
@ -376,13 +386,17 @@ ynh_permission_update() {
#
# Requires YunoHost version 3.7.1 or higher.
ynh_permission_has_user() {
# Declare an array to define the options of this helper.
local legacy_args=pu
declare -Ar args_array=( [p]=permission= [u]=user)
local permission
local user
ynh_handle_getopts_args "$@"
if ! ynh_permission_exists --permission $permission
if ! ynh_permission_exists --permission "$permission"
then
return 1
fi
yunohost user permission info $permission | grep -w -q "$user"
yunohost user permission info "$app.$permission" | grep -w -q "$user"
}