Files
ytdl-patched-mirror/devscripts/bash-completion.py
Lesmiscore 7dd9eb1b60 Merge branch 'master' of https://github.com/yt-dlp/yt-dlp into ytdlp
* 'master' of https://github.com/yt-dlp/yt-dlp:
  [EmbedSubtitle] Enable for more video extensions
  [utils] certifi: Make sure the pem file exists
  [cleanup] Misc cleanup (#2173)
  [cleanup] Sort imports
  [cleanup] Upgrade syntax
  [cleanup] Mark some compat variables for removal (#2173)
  [cleanup] Remove unused code paths (#2173)
  [cleanup] Remove unused scripts/tests (#2173)
  [FFmpegMetadataPP] Remove `\0` from metadata
2022-04-12 11:11:02 +09:00

29 lines
806 B
Python
Executable File

#!/usr/bin/env python3
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()[0]
build_completion(parser)