mirror of
https://github.com/soimort/you-get.git
synced 2025-01-23 05:25:02 +03:00
Add shell completion definitions for Bash, Fish and Zsh
Paths of completion definitions in this repo are inconsequential, and I don't know a convention for that, so I just modelled it on git.git https://github.com/git/git/tree/master/contrib/completion. What's different here is that instead of using a uniform naming scheme for each file (you-get-completion.<shellname>), I'm using the conventional name for each shell, which means _you-get for Zsh, for instance. Users of each shell should be able to pick out the completion definition for their shell based on the filenames; in the worst case, they can still tell from the comment at the top of each file. Note that I'm no expert on Bash or Fish completion, so you-get-completion.bash and you-get.fish may not be written in the idiomatic way. (you-get-completion.bash is most certainly not idiomatic, if there's an idiom at all.) Closes #1178.
This commit is contained in:
parent
cb39f4b9f3
commit
3b4a576e6c
@ -93,6 +93,10 @@ $ git clone git://github.com/soimort/you-get.git
|
||||
|
||||
Then put the cloned directory into your `PATH`, or run `./setup.py install` to install `you-get` to a permanent path.
|
||||
|
||||
### Shell completion
|
||||
|
||||
Completion definitions for Bash, Fish and Zsh can be found in [`contrib/completion`](contrib/completion). Please consult your shell's manual for how to take advantage of them.
|
||||
|
||||
## Upgrading
|
||||
|
||||
Based on which option you chose to install `you-get`, you may upgrade it via:
|
||||
|
29
contrib/completion/_you-get
Normal file
29
contrib/completion/_you-get
Normal file
@ -0,0 +1,29 @@
|
||||
#compdef you-get
|
||||
|
||||
# Zsh completion definition for soimort/you-get.
|
||||
|
||||
setopt localoptions noshwordsplit noksharrays
|
||||
local -a args
|
||||
|
||||
args=(
|
||||
'(- : *)'{-V,--version}'[print version and exit]'
|
||||
'(- : *)'{-h,--help}'[print help and exit]'
|
||||
'(-i --info)'{-i,--info}'[print extracted information]'
|
||||
'(-u --url)'{-u,--url}'[print extracted information with URLs]'
|
||||
'(--json)--json[print extracted URLs in JSON format]'
|
||||
'(-n --no-merge)'{-n,--no-merge}'[do not merge video parts]'
|
||||
'(--no-caption)--no-caption[do not download captions]'
|
||||
'(-f --force)'{-f,--force}'[force overwrite existing files]'
|
||||
'(-F --format)'{-F,--format}'[set video format to the specified stream id]:stream id'
|
||||
'(-O --output-filename)'{-O,--output-filename}'[set output filename]:filename:_files'
|
||||
'(-o --output-dir)'{-o,--output-dir}'[set output directory]:directory:_files -/'
|
||||
'(-p --player)'{-p,--player}'[stream extracted URL to the specified player]:player and options'
|
||||
'(-c --cookies)'{-c,--cookies}'[load cookies.txt or cookies.sqlite]:cookies file:_files'
|
||||
'(-x --http-proxy)'{-x,--http-proxy}'[use the specified HTTP proxy for downloading]:host\:port:'
|
||||
'(-y --extractor-proxy)'{-y,--extractor-proxy}'[use the specified HTTP proxy for extraction only]:host\:port'
|
||||
'(--no-proxy)--no-proxy[do not use a proxy]'
|
||||
'(-t --timeout)'{-t,--timeout}'[set socket timeout]:seconds'
|
||||
'(-d --debug)'{-d,--debug}'[show traceback and other debug info]'
|
||||
'*: :_guard "^-*" url'
|
||||
)
|
||||
_arguments -S -s $args
|
31
contrib/completion/you-get-completion.bash
Executable file
31
contrib/completion/you-get-completion.bash
Executable file
@ -0,0 +1,31 @@
|
||||
# Bash completion definition for you-get.
|
||||
|
||||
_you-get () {
|
||||
COMPREPLY=()
|
||||
local IFS=$' \n'
|
||||
local cur=$2 prev=$3
|
||||
local -a opts_without_arg opts_with_arg
|
||||
opts_without_arg=(
|
||||
-V --version -h --help -i --info -u --url --json -n --no-merge
|
||||
--no-caption -f --force --no-proxy -d --debug
|
||||
)
|
||||
opts_with_arg=(
|
||||
-F --format -O --output-filename -o --output-dir -p --player
|
||||
-c --cookies -x --http-proxy -y --extractor-proxy -t --timeout
|
||||
)
|
||||
|
||||
# Do not complete non option names
|
||||
[[ $cur == -* ]] || return 1
|
||||
|
||||
# Do not complete when the previous arg is an option expecting an argument
|
||||
for opt in "${opts_with_arg[@]}"; do
|
||||
[[ $opt == $prev ]] && return 1
|
||||
done
|
||||
|
||||
# Complete option names
|
||||
COMPREPLY=( $(compgen -W "${opts_without_arg[*]} ${opts_with_arg[*]}" \
|
||||
-- "$cur") )
|
||||
return 0
|
||||
}
|
||||
|
||||
complete -F _you-get you-get
|
23
contrib/completion/you-get.fish
Normal file
23
contrib/completion/you-get.fish
Normal file
@ -0,0 +1,23 @@
|
||||
# Fish completion definition for you-get.
|
||||
|
||||
complete -c you-get -s V -l version -d 'print version and exit'
|
||||
complete -c you-get -s h -l help -d 'print help and exit'
|
||||
complete -c you-get -s i -l info -d 'print extracted information'
|
||||
complete -c you-get -s u -l url -d 'print extracted information'
|
||||
complete -c you-get -l json -d 'print extracted URLs in JSON format'
|
||||
complete -c you-get -s n -l no-merge -d 'do not merge video parts'
|
||||
complete -c you-get -l no-caption -d 'do not download captions'
|
||||
complete -c you-get -s f -l force -d 'force overwrite existing files'
|
||||
complete -c you-get -s F -l format -x -d 'set video format to the specified stream id'
|
||||
complete -c you-get -s O -l output-filename -d 'set output filename' \
|
||||
-x -a '(__fish_complete_path (commandline -ct) "output filename")'
|
||||
complete -c you-get -s o -l output-dir -d 'set output directory' \
|
||||
-x -a '(__fish_complete_directories (commandline -ct) "output directory")'
|
||||
complete -c you-get -s p -l player -x -d 'stream extracted URL to the specified player'
|
||||
complete -c you-get -s c -l cookies -d 'load cookies.txt or cookies.sqlite' \
|
||||
-x -a '(__fish_complete_path (commandline -ct) "cookies.txt or cookies.sqlite")'
|
||||
complete -c you-get -s x -l http-proxy -x -d 'use the specified HTTP proxy for downloading'
|
||||
complete -c you-get -s y -l extractor-proxy -x -d 'use the specified HTTP proxy for extraction only'
|
||||
complete -c you-get -l no-proxy -d 'do not use a proxy'
|
||||
complete -c you-get -s t -l timeout -x -d 'set socket timeout'
|
||||
complete -c you-get -s d -l debug -d 'show traceback and other debug info'
|
Loading…
Reference in New Issue
Block a user