mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
849 B
Python
33 lines
849 B
Python
#!/usr/bin/env python3
|
|
|
|
# Allow direct execution
|
|
import os
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
import yt_dlp
|
|
from devscripts.utils import gather_completion_opts
|
|
|
|
ZSH_COMPLETION_FILE = 'completions/zsh/_yt-dlp'
|
|
ZSH_COMPLETION_TEMPLATE = 'devscripts/zsh-completion.in'
|
|
|
|
|
|
def build_completion(opt_parser):
|
|
opts = gather_completion_opts(opt_parser)
|
|
|
|
with open(ZSH_COMPLETION_TEMPLATE) as f:
|
|
template = f.read()
|
|
|
|
template = template.replace('{{fileopts}}', '|'.join(opts.file_opts))
|
|
template = template.replace('{{diropts}}', '|'.join(opts.dir_opts))
|
|
template = template.replace('{{flags}}', ' '.join(opts.opts))
|
|
|
|
with open(ZSH_COMPLETION_FILE, 'w') as f:
|
|
f.write(template)
|
|
|
|
|
|
parser = yt_dlp.parseOpts(ignore_config_files=True)[0]
|
|
build_completion(parser)
|