Skip to content

Instantly share code, notes, and snippets.

@Ram-Z
Created January 13, 2015 10:42
Show Gist options
  • Save Ram-Z/9e45a55a020e73cf744d to your computer and use it in GitHub Desktop.
Save Ram-Z/9e45a55a020e73cf744d to your computer and use it in GitHub Desktop.
#compdef flexget
(( $+functions[_flexget_command] )) || _flexget_command()
{
local -a _flexget_cmds
_flexget_cmds=(
'execute:execute tasks now'
'daemon:run continuously, executing tasks according to schedules defined in config'
'check:validate configuration file and print errors'
'movie-queue:view and manage the movie queue'
'series:view and manipulate the series plugin database'
'database:utilities to manage the FlexGet database'
'plugins:print registered plugin summaries'
'doc:display plugin documentation'
'history:view the history of entries that FlexGet has accepted'
'rejected:list or clear remembered rejections'
'seen:view or forget entries remembered by the seen plugin'
'failed:list or clear remembered failures'
'archive:search and manipulate the archive database'
'inject:inject an entry from command line into tasks'
)
if (( CURRENT == 1)); then
_describe -t commands 'flexget command' _flexget_cmds || compadd "$@"
else
local curcontext="$curcontext"
cmd="${${_flexget_cmds[(r)$words[1]:*]%%:*}}"
if (( $#cmd )); then
curcontext="${curcontext%:*:*}:flexget-${cmd}:"
local update_policy
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:${curcontext}:" cache-policy _flexget_caching_policy
fi
_call_function ret _flexget_$cmd || _message 'no more arguments'
else
_message "unknown flexget command: $words[1]"
fi
return ret
fi
}
(( $+functions[_flexget_tasks] )) || _flexget_tasks()
{
#TODO
}
(( $+functions[_flexget_cli_config] )) || _flexget_cli_config()
{
#TODO
}
(( $+functions[_flexget_template] )) || _flexget_template()
{
#TODO
}
(( $+functions[_flexget_execute] )) || _flexget_execute()
{
_arguments -s \
{-h,--help}'[Show help]' \
'--tasks[run only specified task(s)]:tasks:_flexget_tasks' \
'--learn[matches are not downloaded but will be skipped in the future]' \
'--no-cache[disable caches. works only in plugins that have explicit support]' \
'--stop-waiting[stop timeframe for a given series]' \
'--disable-tracking[disable episode advancement for this run]' \
'--cli-config[configuration parameters trough commandline]:config parameters:_flexget_cli_config' \
'--dl-path[override path for download plugin, applies to all executed tasks]:directory:_directories' \
'--dump[display all entries in task with fields they contain]' \
'--dump-config[display the config of each feed after template merging/config generation occurs]' \
'--now[run task(s) even if the interval plugin would normally prevent it]' \
'--discover-now[immediately try to discover everything]' \
'--tail-reset[reset tail position for a file]' \
'--template[execute tasks using given template]:template:_flexget_template' \
{-v,--verbose}'[verbose undecided entries]' \
{-s,--silent}'[don''t verbose any actions (accept, reject, fail)]' \
'--try-regexp[try regular expressions interactively]'
}
(( $+functions[_flexget_daemon] )) || _flexget_daemon()
{
local -a _flexget_daemon_cmds
_flexget_daemon_cmds=(
'start:start the daemon'
'stop:shutdown the running daemon'
'status:check if a daemon is running'
'reload:causes a running daemon to reload the config from disk'
)
if (( CURRENT == 2 )); then
_describe -t commands 'flexget daemon command' _flexget_daemon_cmds
fi
_arguments -s \
{-h,--help}'[Show help]'
}
_arguments -s \
{-h,--help}'[Show help]' \
{-V,--version}'[Print FlexGet version and exit.]' \
'--test[Verbose what would happen on normal execution.]' \
'-c[Specify configuration file.]:file:_files' \
{-l+,--logfile}'[Specify a custom logfile name/location.]:file:_files' \
{-L+,--loglevel}'[Set the verbosity of the logger]:loglevel:(none critical error warning info verbose debug trace)' \
'--bugreport[Create a detailed bug report]' \
'--profile[Use the python profiler for this run to debug performance issues.]:file:_files' \
'--cron[Executing FlexGet non-interactively]' \
'--debug-db-sessions[Debug session starts and ends, for finding problems with db locks]' \
'--debug-warnings[Elevate warnings to errors for debugging purposes, so a traceback is shown]' \
'*::flexget command:_flexget_command'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment