Files
ytdl-patched-mirror/devscripts/bash-completion.py
Lesmiscore 8a9198d0a9 Merge branch 'ytdlp' of github.com:ytdl-patched/ytdl-patched; branch 'master' of https://github.com/yt-dlp/yt-dlp into ytdlp
* 'ytdlp' of github.com:ytdl-patched/ytdl-patched:
* 'master' of https://github.com/yt-dlp/yt-dlp:
  [compat] Remove deprecated functions from core code
  [cleanup] Consistent style for file heads
  [compat] Remove more functions
  [compat] Fix `compat.WINDOWS_VT_MODE`
  Fix `section_end` of clips
2022-06-25 10:11:25 +09:00

32 lines
857 B
Python
Executable File

#!/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
BASH_COMPLETION_FILE = "youtube-dl.bash-completion"
BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.in"
def build_completion(opt_parser):
opts_flag = []
for group in opt_parser.option_groups:
for option in group.option_list:
# for every long flag
opts_flag.append(option.get_opt_string())
with open(BASH_COMPLETION_TEMPLATE) as f:
template = f.read()
with open(BASH_COMPLETION_FILE, "w") as f:
# just using the special char
filled_template = template.replace("{{flags}}", " ".join(opts_flag))
f.write(filled_template)
parser = yt_dlp.parseOpts(ignore_config_files=True)[0]
build_completion(parser)