karnel-termux 4.9.6 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/karnel/cli/commands/plugin.sh +37 -0
- package/karnel/utils/env.sh +1 -1
- package/package.json +1 -1
|
@@ -34,6 +34,9 @@ plugin_main() {
|
|
|
34
34
|
list|ls)
|
|
35
35
|
_list_plugins
|
|
36
36
|
;;
|
|
37
|
+
search)
|
|
38
|
+
_search_plugins
|
|
39
|
+
;;
|
|
37
40
|
create|scaffold)
|
|
38
41
|
if [[ $# -lt 1 ]]; then
|
|
39
42
|
log_error "Usage: karnel plugin create <name>"
|
|
@@ -61,6 +64,7 @@ plugin_help() {
|
|
|
61
64
|
printf " ${D_CYAN}%-20s${NC} %s\n" "remove <name>" "Uninstall a plugin"
|
|
62
65
|
printf " ${D_CYAN}%-20s${NC} %s\n" "update <name>" "Update a plugin"
|
|
63
66
|
printf " ${D_CYAN}%-20s${NC} %s\n" "list" "List installed plugins"
|
|
67
|
+
printf " ${D_CYAN}%-20s${NC} %s\n" "search" "Search available plugins in the registry"
|
|
64
68
|
printf " ${D_CYAN}%-20s${NC} %s\n" "create <name>" "Scaffold a new plugin"
|
|
65
69
|
echo
|
|
66
70
|
echo "Plugins are installed from GitHub repos."
|
|
@@ -71,9 +75,42 @@ plugin_help() {
|
|
|
71
75
|
echo " karnel plugin install username/my-karnel-plugin"
|
|
72
76
|
echo " karnel plugin list"
|
|
73
77
|
echo " karnel plugin remove my-karnel-plugin"
|
|
78
|
+
echo " karnel plugin search"
|
|
74
79
|
echo " karnel plugin create my-plugin"
|
|
75
80
|
}
|
|
76
81
|
|
|
82
|
+
_search_plugins() {
|
|
83
|
+
local registry_url="https://raw.githubusercontent.com/israelmarques1024-dotcom/karnel-plugins/main/registry.json"
|
|
84
|
+
log_info "Fetching plugin registry..."
|
|
85
|
+
local data
|
|
86
|
+
data="$(curl -sfL "$registry_url" 2>/dev/null)" || {
|
|
87
|
+
log_error "Failed to fetch registry. Check internet connection."
|
|
88
|
+
return 1
|
|
89
|
+
}
|
|
90
|
+
local count
|
|
91
|
+
count="$(echo "$data" | sed -n 's/.*"plugins": \[\(.*\)\]/\1/p' | grep -o '"name"' | wc -l)"
|
|
92
|
+
if [[ "$count" -eq 0 ]]; then
|
|
93
|
+
echo " No plugins available in the registry yet."
|
|
94
|
+
echo " Be the first: https://github.com/israelmarques1024-dotcom/karnel-plugins"
|
|
95
|
+
return 0
|
|
96
|
+
fi
|
|
97
|
+
echo
|
|
98
|
+
box "Available Plugins ($count)"
|
|
99
|
+
echo
|
|
100
|
+
local names
|
|
101
|
+
names="$(echo "$data" | sed 's/.*"plugins":\[//;s/\]$//' | tr '}' '\n' | while IFS= read -r entry; do
|
|
102
|
+
[[ -z "$entry" ]] && continue
|
|
103
|
+
local n d r c
|
|
104
|
+
n="$(echo "$entry" | sed -n 's/.*"name":"\([^"]*\)".*/\1/p')"
|
|
105
|
+
d="$(echo "$entry" | sed -n 's/.*"description":"\([^"]*\)".*/\1/p')"
|
|
106
|
+
r="$(echo "$entry" | sed -n 's/.*"repo":"\([^"]*\)".*/\1/p')"
|
|
107
|
+
printf " ${D_GREEN}%-20s${NC} %s\n" "$n" "$d"
|
|
108
|
+
printf " ${D_CYAN} install:${NC} karnel plugin install %s\n" "$r"
|
|
109
|
+
done)"
|
|
110
|
+
echo "$names"
|
|
111
|
+
echo
|
|
112
|
+
}
|
|
113
|
+
|
|
77
114
|
_scaffold_plugin() {
|
|
78
115
|
local name="$1"
|
|
79
116
|
local dir="$(_plugin_dir "$name")"
|
package/karnel/utils/env.sh
CHANGED
package/package.json
CHANGED