ytdl-org / youtube-dl

Command-line program to download videos from YouTube.com and other video sites
http://ytdl-org.github.io/youtube-dl/
The Unlicense
131.42k stars 9.96k forks source link

Add prompt information for zsh completions #30900

Open Freed-Wu opened 2 years ago

Freed-Wu commented 2 years ago

Checklist

Description

WRITE DESCRIPTION HERE

Now, the completion of youtube-dl is: (e.g. zsh)

❯ youtube-dl --<Tab>
--abort-on-error                 --dump-pages                     --hls-prefer-native              --no-continue                    --rm-cache-dir
...

How about:

❯ youtube-dl --<Tab>
option
--abort-on-error                  Abort downloading of further videos (in the playlist or the command line) if an error occurs
--abort-on-unavailable-fragment   Abort downloading when some fragment is not available
...

It is just

#compdef youtube-dl

compdef _gnu_generic youtube-dl

I believe if use youtube-dl --completion zsh to generate a shell script, it can be done better.

dirkf commented 2 years ago

My expertise only goes as far as https://github.com/zsh-users/zsh-completions, but yt-dl has a GNU-like --help. Although yt-dl has a zsh completion, what happens with this?

compdef _gnu_generic youtube-dl
Freed-Wu commented 2 years ago

compdef _gnu_geneirc XXX is just a fallback solution, it use zsh to parse XXX --help to get a completion, but it is slow than the provided completion script. And it cannot provide higher functions, such as:

❯ youtube-dl --convert-subs <Tab>
selection
ass  lrc  srt  vtt
❯ youtube-dl --proxy <Tab>
URL
file:      ftp://     gopher://  http://    https://