diff options
author | Philipp Hagemeister <phihag@phihag.de> | 2012-12-11 07:52:44 -0800 |
---|---|---|
committer | Philipp Hagemeister <phihag@phihag.de> | 2012-12-11 07:52:44 -0800 |
commit | d050de77f94a5dc9071c0b459ba62cb09c6696c4 (patch) | |
tree | 3bea4b6975544ef76241ccf402de541da350b4ac /devscripts/bash-completion.py | |
parent | 4fb1acc212555e3e817f858dce964876eef75d85 (diff) | |
parent | 95eb771dcda47f948b050da85c7ff22539e3ee12 (diff) |
Merge pull request #580 from FiloSottile/master
The new shiny build system
Diffstat (limited to 'devscripts/bash-completion.py')
-rw-r--r-- | devscripts/bash-completion.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/devscripts/bash-completion.py b/devscripts/bash-completion.py new file mode 100644 index 000000000..880db7886 --- /dev/null +++ b/devscripts/bash-completion.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python +import os +from os.path import dirname as dirn +import sys + +sys.path.append(dirn(dirn((os.path.abspath(__file__))))) +import youtube_dl + +BASH_COMPLETION_FILE = "youtube-dl.bash-completion" +BASH_COMPLETION_TEMPLATE = "devscripts/bash-completion.template" + +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 = youtube_dl.parseOpts()[0] +build_completion(parser) |