Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add complete for shell by shtab #2976

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

Freed-Wu
Copy link

❯ you-get --print-completion bash | sudo tee /usr/share/bash-completion/completions/you-get
❯ you-get --print-completion zsh | sudo tee /usr/share/zsh/site-functions/_you-get
❯ you-get --print-completion tcsh|sudo tee /etc/profile.d/you-get.completion.csh

Because shtab's bug for zsh, I temporarily fix it and sent a PR to shtab. A
fixed version:

❯ you-get --print-completion zsh | xsel -ib
#compdef you-get

# AUTOMATCALLY GENERATED by `shtab`


_shtab_you_get_commands() {
  local _commands=(
    
  )
  _describe 'you-get commands' _commands
}

_shtab_you_get_options=(
  "(- : *)--print-completion[print shell completion script]:print_completion:(bash zsh tcsh)"
  {-V,--version}"[Print version and exit]"
  {-h,--help}"[Print this help message and exit]"
  {-i,--info}"[Print extracted information]"
  {-u,--url}"[Print extracted information with URLs]"
  "--json[Print extracted URLs in JSON format]"
  {-n,--no-merge}"[Do not merge video parts]"
  "--no-caption[Do not download captions (subtitles, lyrics, danmaku, ...)]"
  "--postfix[Postfix downloaded files with unique identifiers]"
  {-f,--force}"[Force overwriting existing files]"
  "--skip-existing-file-size-check[Skip existing file without checking file size]"
  {-F,--format}"[Set video format to STREAM_ID]:format:"
  {-O,--output-filename}"[Set output filename]:output_filename:_files"
  {-o,--output-dir}"[Set output directory]:output_dir:_files -/"
  {-p,--player}"[Stream extracted URL to a PLAYER]:player:"
  {-c,--cookies}"[Load cookies.txt or cookies.sqlite]:cookies:_files"
  {-t,--timeout}"[Set socket timeout]:timeout:"
  {-d,--debug}"[Show traceback and other debug info]"
  {-I,--input-file}"[Read non-playlist URLs from FILE]:input_file:_files"
  {-P,--password}"[Set video visit password to PASSWORD]:password:"
  {-l,--playlist}"[Prefer to download a playlist]"
  "--first[the first number]:first:"
  "--last[the last number]:last:"
  {--size,--page-size}"[the page size number]:size:"
  {-a,--auto-rename}"[Auto rename same name different files]"
  {-k,--insecure}"[ignore ssl errors]"
  {-x,--http-proxy}"[Use an HTTP proxy for downloading]:http_proxy:_hosts"
  {-y,--extractor-proxy}"[Use an HTTP proxy for extracting only]:extractor_proxy:_hosts"
  "--no-proxy[Never use a proxy]"
  {-s,--socks-proxy}"[Use an SOCKS5 proxy for downloading]:socks_proxy:_hosts_users"
  {-m,--m3u8}"[download video using an m3u8 url]"
  "(*)::URL:_urls"
)


_shtab_you_get() {
  local context state line curcontext="$curcontext"

  one_or_more='(-)*'
  reminder='(*)'
  if ((${_shtab_you_get_options[(I)${(q)one_or_more}*]} + ${_shtab_you_get_options[(I)${(q)reminder}*]} == 0)); then  # noqa: E501
    _shtab_you_get_options+=(': :_shtab_you_get_commands' '*::: :->you-get')
  fi
  _arguments -C $_shtab_you_get_options

  case $state in
    you-get)
      words=($line[1] "${words[@]}")
      (( CURRENT += 1 ))
      curcontext="${curcontext%:*:*}:_shtab_you_get-$line[1]:"
      case $line[1] in
        
      esac
  esac
}

# Custom Preamble
_hosts_users() {
  _alternative 'hosts: :_hosts' 'users: :_users'
}

# End Custom Preamble


typeset -A opt_args
_shtab_you_get "$@"

you-get --print-completion bash | sudo tee /usr/share/bash-completion/completions/you-get
you-get --print-completion zsh | sudo tee /usr/share/zsh/site-functions/_you-get
you-get --print-completion tcsh|sudo tee /etc/profile.d/you-get.completion.csh
@soimort-bot
Copy link
Collaborator

Hello @Freed-Wu,
Thanks for the Pull Request. We ❤️ our contributors!
Please wait for one of our human maintainers to review your patches. This may take a few days to weeks. Also, please understand that although your Pull Request may or may not be eventually merged, we value all contributions equally.

祝您健康!

@Freed-Wu
Copy link
Author

@soimort

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants