hide API only, complete app_catalog, show only usernames not emails

This commit is contained in:
getzze 2023-09-11 13:17:00 +01:00
parent 5bbd9cece2
commit 22ac5c0563
2 changed files with 37 additions and 24 deletions

View file

@ -146,7 +146,9 @@ def make_category(category_name: str, category_map: dict) -> str:
# First, complete the main action map # First, complete the main action map
for action, action_details in category_map["actions"].items(): for action, action_details in category_map["actions"].items():
# Empty element failsafe # Empty element failsafe
if "action_help" not in action_details and "arguments" not in action_details: if action_details.get("hide_in_help", False) or (
"action_help" not in action_details and "arguments" not in action_details
):
continue continue
# Adding the new action to the map of the category # Adding the new action to the map of the category
@ -259,6 +261,16 @@ def make_argument_list(action_map: dict, spaces: str = 4 * " ") -> str:
# (eg.: `firewall allow... -4`) # (eg.: `firewall allow... -4`)
argument_name = str(argument_name) argument_name = str(argument_name)
#
# Check if the argument should be hidden (API only)
#
if (
argument_details.get("extra", {})
.get("autocomplete", {})
.get("hide_in_help", False)
):
continue
# #
# Generation of the completion hints # Generation of the completion hints
# #
@ -580,7 +592,7 @@ __yunohost_cache_policy(){
local -a oldp local -a oldp
# oldp=( "$1"(mM+1) ) # month # oldp=( "$1"(mM+1) ) # month
# oldp=( "$1"(Nm+7) ) # 1 week # oldp=( "$1"(Nm+7) ) # 1 week
oldp=( "$1"(Nmm+1) ) # 1 min oldp=( "$1"(Nmd+1) ) # 1 day
(( $#oldp )) && return (( $#oldp )) && return
return 1 return 1
} }

View file

@ -171,9 +171,9 @@ user:
help: Username to delete help: Username to delete
extra: extra:
pattern: *pattern_username pattern: *pattern_username
autocomplete: &usernames_and_mails_list autocomplete: &users_list
ynh_selector: user list ynh_selector: user list --fields username
jq_selector: '.users[].username, .users[].mail' jq_selector: '.users[].username'
use_cache: false use_cache: false
--purge: --purge:
help: Purge user's home and mail directories help: Purge user's home and mail directories
@ -187,10 +187,7 @@ user:
username: username:
help: Username to update help: Username to update
extra: extra:
autocomplete: &users_list autocomplete: *users_list
ynh_selector: user list --fields username
jq_selector: '.users[].username'
use_cache: false
-F: -F:
full: --fullname full: --fullname
help: The full name of the user. For example 'Camille Dupont' help: The full name of the user. For example 'Camille Dupont'
@ -262,7 +259,7 @@ user:
username: username:
help: Username or email to get information help: Username or email to get information
extra: extra:
autocomplete: *usernames_and_mails_list autocomplete: *users_list
### user_export() ### user_export()
export: export:
@ -279,7 +276,7 @@ user:
type: open type: open
extra: extra:
autocomplete: autocomplete:
zsh_completion: _file zsh_completion: _files
-u: -u:
full: --update full: --update
help: Update all existing users contained in the CSV file (by default existing users are ignored) help: Update all existing users contained in the CSV file (by default existing users are ignored)
@ -728,7 +725,7 @@ domain:
### domain_url_available() ### domain_url_available()
url-available: url-available:
hide_in_help: True hide_in_help: true
action_help: Check availability of a web path action_help: Check availability of a web path
api: GET /domain/<domain>/urlavailable api: GET /domain/<domain>/urlavailable
arguments: arguments:
@ -743,7 +740,7 @@ domain:
### domain_action_run() ### domain_action_run()
action-run: action-run:
hide_in_help: True hide_in_help: true
action_help: Run domain action action_help: Run domain action
api: PUT /domain/<domain>/actions/<action> api: PUT /domain/<domain>/actions/<action>
arguments: arguments:
@ -993,11 +990,17 @@ app:
app: app:
help: Name, local path or git URL of the app to fetch the manifest of help: Name, local path or git URL of the app to fetch the manifest of
extra: extra:
autocomplete: *apps_list autocomplete: &apps_catalog_list
ynh_selector: app catalog
jq_selector: '.apps | keys[]'
use_cache: true
-s: -s:
full: --with-screenshot full: --with-screenshot
help: Also return a base64 screenshot if any (API only) help: Also return a base64 screenshot if any (API only)
action: store_true action: store_true
extra:
autocomplete:
hide_in_help: true
### app_list() ### app_list()
list: list:
@ -1056,7 +1059,7 @@ app:
app: app:
help: Name, local path or git URL of the app to install help: Name, local path or git URL of the app to install
extra: extra:
autocomplete: *apps_list autocomplete: *apps_catalog_list
-l: -l:
full: --label full: --label
help: Custom name for the app help: Custom name for the app
@ -1171,7 +1174,7 @@ app:
### app_register_url() ### app_register_url()
register-url: register-url:
hide_in_help: True hide_in_help: true
action_help: Book/register a web path for a given app action_help: Book/register a web path for a given app
arguments: arguments:
app: app:
@ -1188,7 +1191,7 @@ app:
### app_makedefault() ### app_makedefault()
makedefault: makedefault:
hide_in_help: True hide_in_help: true
action_help: Redirect domain root to an app action_help: Redirect domain root to an app
api: PUT /apps/<app>/default api: PUT /apps/<app>/default
arguments: arguments:
@ -1208,7 +1211,7 @@ app:
### app_dismiss_notification ### app_dismiss_notification
dismiss-notification: dismiss-notification:
hide_in_help: True hide_in_help: true
action_help: Dismiss post_install or post_upgrade notification action_help: Dismiss post_install or post_upgrade notification
api: PUT /apps/<app>/dismiss_notification/<name> api: PUT /apps/<app>/dismiss_notification/<name>
arguments: arguments:
@ -1417,14 +1420,12 @@ backup:
### backup_download() ### backup_download()
download: download:
hide_in_help: True hide_in_help: true
action_help: (API only) Request to download the file action_help: (API only) Request to download the file
api: GET /backups/<name>/download api: GET /backups/<name>/download
arguments: arguments:
name: name:
help: Name of the local backup archive help: Name of the local backup archive
extra:
autocomplete: *backups_list
### backup_delete() ### backup_delete()
delete: delete:
@ -2092,7 +2093,7 @@ hook:
### hook_info() ### hook_info()
info: info:
hide_in_help: True hide_in_help: true
action_help: Get information about a given hook action_help: Get information about a given hook
arguments: arguments:
action: action:
@ -2142,7 +2143,7 @@ hook:
### hook_callback() ### hook_callback()
callback: callback:
hide_in_help: True hide_in_help: true
action_help: Execute all scripts binded to an action action_help: Execute all scripts binded to an action
arguments: arguments:
action: action:
@ -2166,7 +2167,7 @@ hook:
### hook_exec() ### hook_exec()
exec: exec:
hide_in_help: True hide_in_help: true
action_help: Execute hook from a file with arguments action_help: Execute hook from a file with arguments
arguments: arguments:
path: path: