use dynamic completion but it seems we should use cache

This commit is contained in:
Shohei YOSHIDA 2026-03-24 18:02:45 +09:00
parent 2fdd13ab92
commit e118561a37
No known key found for this signature in database
GPG Key ID: C9A1BB11BB940CF2
1 changed files with 72 additions and 100 deletions

View File

@ -393,9 +393,11 @@ _mix() {
} }
_mix_tasks() { _mix_tasks() {
# mix help | \grep -vE 'phx\.|hex\.' | perl -wln -e 'm{^mix (\S+)\s+#\s+(.+)} and print qq("$1:$2")' local -a mix_tasks=()
# mix compile --list | perl -wln -e 'm{^mix (\S+)\s+#\s+(.+)} and print qq("$1:$2")' if (( $+commands[perl] )); then
local -a mix_tasks=( mix_tasks=(${(f)"$(mix help | perl -lne 'm{^mix (\S+)\s+#\s+(.+)} and print qq($1:$2)')"})
else
local -a builtin_tasks=(
"app.config:Configures all registered apps" "app.config:Configures all registered apps"
"app.start:Starts all registered apps" "app.start:Starts all registered apps"
"app.tree:Prints the application tree" "app.tree:Prints the application tree"
@ -442,7 +444,6 @@ _mix_tasks() {
"xref:Prints cross reference information" "xref:Prints cross reference information"
) )
# hex is a package manager
# mix help | perl -wln -e 'm{^mix (hex\.\S+)\s+#\s+(.+)} and print qq("$1:$2")' # mix help | perl -wln -e 'm{^mix (hex\.\S+)\s+#\s+(.+)} and print qq("$1:$2")'
local -a hex_tasks=( local -a hex_tasks=(
"hex.audit:Shows retired Hex deps for the current project" "hex.audit:Shows retired Hex deps for the current project"
@ -463,39 +464,10 @@ _mix_tasks() {
"hex.user:Manages your Hex user account" "hex.user:Manages your Hex user account"
) )
# mix help | perl -wln -e 'm{^mix (phx\.\S+)\s+#\s+(.+)} and print qq("$1:$2")' mix_tasks=($builtin_tasks[@] $hex_tasks[@])
local -a phoenix_tasks=( fi
"phx.digest:Digests and compresses static files"
"phx.digest.clean:Removes old versions of static assets."
"phx.gen:Lists all available Phoenix generators"
"phx.gen.auth:Generates authentication logic for a resource"
"phx.gen.cert:Generates a self-signed certificate for HTTPS testing"
"phx.gen.channel:Generates a Phoenix channel"
"phx.gen.context:Generates a context with functions around an Ecto schema"
"phx.gen.embedded:Generates an embedded Ecto schema file"
"phx.gen.html:Generates context and controller for an HTML resource"
"phx.gen.json:Generates context and controller for a JSON resource"
"phx.gen.live:Generates LiveView, templates, and context for a resource"
"phx.gen.notifier:Generates a notifier that delivers emails by default"
"phx.gen.presence:Generates a Presence tracker"
"phx.gen.release:Generates release files and optional Dockerfile for release-based deployments"
"phx.gen.schema:Generates an Ecto schema and migration file"
"phx.gen.secret:Generates a secret"
"phx.gen.socket:Generates a Phoenix socket handler"
"phx.new:Creates a new Phoenix v1.8.5 application"
"phx.new.ecto:Creates a new Ecto project within an umbrella project"
"phx.new.web:Creates a new Phoenix web project within an umbrella project"
"phx.routes:Prints all routes"
"phx.server:Starts applications and their servers"
)
local -a tasks=( _describe -t tasks 'task' mix_tasks
$mix_tasks[@]
$hex_tasks[@]
$phoenix_tasks[@]
)
_describe -t tasks 'task' tasks
} }
_mix_profile_tasks() { _mix_profile_tasks() {