summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMubashshir2020-07-05 13:26:28 +0600
committerMubashshir2020-07-05 13:26:28 +0600
commited3660cb396768017c6cc5518813b4215a8b78b3 (patch)
tree83f15f0937b72098b4ce3cb97b6acd30e22886a1
parenta8337639cc4ac2a871d3a898a297b0ff873a4e32 (diff)
downloadaur-ed3660cb396768017c6cc5518813b4215a8b78b3.tar.gz
added zsh autocomplete.
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD13
-rw-r--r--trakts.zsh252
3 files changed, 264 insertions, 5 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 9b05f05594c5..67ae862ac9e2 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = trakt-scrobbler
pkgdesc = Automatically scrobble TV show episodes and movies you are watching to Trakt.tv! It keeps a history of everything you've watched!
pkgver = 1.0.0b10
- pkgrel = 2
+ pkgrel = 3
url = https://github.com/iamkroot/trakt-scrobbler
arch = any
license = GPL2
@@ -29,8 +29,10 @@ pkgbase = trakt-scrobbler
optdepends = python-gobject: Provides Updatable Notifications.
source = https://files.pythonhosted.org/packages/source/t/trakt-scrobbler/trakt-scrobbler-1.0.0b10.tar.gz
source = trakts-man.md
+ source = trakts.zsh
sha256sums = 8057f7cad2e95c72c8c43edfc01499b633320106d305bf25e80793399ffae0d4
sha256sums = 81c3fb93bf01c0e6c0bbc9b2ef853da3f691bc3c50b4a87a68072b11ba72691c
+ sha256sums = db26192ab3f8bdafe6a153cddd3c933410d0c566b54b9ce3491edfe2d789eac8
pkgname = trakt-scrobbler
diff --git a/PKGBUILD b/PKGBUILD
index 6ada069ec6ef..d882280da04f 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@
pkgname=trakt-scrobbler
pkgver=1.0.0b10
-pkgrel=2
+pkgrel=3
pkgdesc="Automatically scrobble TV show episodes and movies you are watching to Trakt.tv! It keeps a history of everything you've watched!"
arch=(any)
@@ -14,10 +14,14 @@ optdepends=(
'libnotify: Provides Desktop Notifications.'
'python-gobject: Provides Updatable Notifications.'
)
-source=(https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz
- trakts-man.md)
+source=(
+ "https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz"
+ "trakts-man.md"
+ "trakts.zsh"
+)
sha256sums=('8057f7cad2e95c72c8c43edfc01499b633320106d305bf25e80793399ffae0d4'
- '81c3fb93bf01c0e6c0bbc9b2ef853da3f691bc3c50b4a87a68072b11ba72691c')
+ '81c3fb93bf01c0e6c0bbc9b2ef853da3f691bc3c50b4a87a68072b11ba72691c'
+ 'db26192ab3f8bdafe6a153cddd3c933410d0c566b54b9ce3491edfe2d789eac8')
build() {
cd "$srcdir/$pkgname-$pkgver"
python setup.py build
@@ -32,4 +36,5 @@ package()
cd "$srcdir/$pkgname-$pkgver"
python setup.py install --root="$pkgdir" --optimize=1 --skip-build
install -Dm644 "trakts.1.gz" "$pkgdir/usr/share/man/man1/trakts.1.gz"
+ install -Dm755 "$srcdir/trakts.zsh" "$pkgdir/usr/share/zsh/site-functions/_trakts"
}
diff --git a/trakts.zsh b/trakts.zsh
new file mode 100644
index 000000000000..8d3857f11cb6
--- /dev/null
+++ b/trakts.zsh
@@ -0,0 +1,252 @@
+#compdef trakts
+#
+# Zsh auto complete function for zsh
+#
+
+# Section: trakts autostart
+_trakts_autostart_actions()
+{
+ local actions
+ actions=(
+ "enable:Install and enable the autostart service"
+ "disable:Disable the autostart service"
+ )
+ _describe 'actions' actions
+}
+# command: trakts autostart
+_trakts_autostart()
+{
+ _arguments '1:action:_trakts_autostart_actions'
+}
+# Section: trakts backlog
+_trakts_backlog_actions()
+{
+ local actions
+ actions=(
+ "clear:Try to sync the backlog with trakt servers"
+ "list:List the files in backlog"
+ )
+ _describe 'actions' actions
+}
+# command: trakts backlog
+_trakts_backlog()
+{
+ _arguments '1:action:_trakts_backlog_actions'
+}
+
+# Section: trakts config
+_trakts_config_actions()
+{
+ local actions
+ actions=(
+ 'list:List configuration settings'
+ 'set:Set the value for a config parameter'
+ 'unset:Reset a config value to its default'
+ )
+ _describe 'actions' actions
+}
+# command: trakts config
+_trakts_config()
+{
+ local args line
+ args=(
+ '1:action:_trakts_config_actions'
+ '*::arg:->args'
+ )
+ _arguments -s "${args[@]}"
+ case $line[1] in
+ (list)
+ _arguments '--all[Include default values]'
+ ;;
+ (set)
+ _trakts_config_set "$@"
+ ;;
+ (unset)
+ _trakts_config_list "$@"
+ ;;
+ esac
+}
+# command: trakts config set
+_trakts_config_set()
+{
+ local args
+ args=(
+ '1:key:_trakts_config_list'
+ '2:value:'
+ '--add[Append to list instead of overwriting]'
+ )
+ _arguments -s "${args[@]}"
+}
+# command: trakts config list
+_trakts_config_list()
+{
+ local keys
+ keys=(
+ $(trakts config list --all|cut -d\ -f1)
+ )
+ _describe 'keys' keys
+}
+
+# Section: trakts init
+_trakts_init_actions()
+{
+ true
+}
+# command: trakts init
+_trakts_init()
+{
+ _arguments '1:action:_trakts_init_actions'
+}
+# no subcommand or options provided
+
+# Section: trakts log
+_trakts_log_actions()
+{
+ local actions
+ actions=(
+ 'open:Open Latest log.'
+ 'path:Prints the location of the log file'
+ )
+ _describe 'actions' actions
+}
+# command: trakts log
+_trakts_log()
+{
+ _arguments '1:action:_trakts_log_actions'
+}
+
+# Section: trakts plex
+# command: trakts plex
+_trakts_plex()
+{
+ _arguments -s '-f[Force run the flow]'
+}
+
+# Section: trakts run
+# command: trakts run
+_trakts_run()
+{
+ true
+}
+
+# Section: trakts start
+# command: trakts start
+_trakts_start()
+{
+ _arguments -s {-r,--restart}'[Restart the service]'
+}
+
+# Section: trakts status
+# command: trakts status
+_trakts_status()
+{
+ true
+}
+
+# Section: trakts stop
+# command: trakts stop
+_trakts_stop()
+{
+ true
+}
+
+# Section: trakts whitelist
+_trakts_whitelist_actions()
+{
+ local actions
+ actions=(
+ 'add:Add folder(s) to whitelist'
+ 'remove:Remove folder(s) from whitelist'
+ 'show:Show the current whitelist'
+ 'test:Check whether the given file/folder is whitelisted'
+ )
+ _describe 'actions' actions
+}
+# command: trakts whitelist
+_trakts_whitelist()
+{
+ local line state
+ _arguments '1:action:_trakts_whitelist_actions' '::path:->path'
+ case $line[1] in
+ (add)
+ _path_files -/
+ ;;
+ (test)
+ _path_files
+ ;;
+ (*) true;;
+ esac
+}
+
+# Section: trakts
+_trakts_actions()
+{
+ local state actions
+ actions=(
+ "auth:Runs the authetication flow for trakt.tv"
+ "autostart:Controls the autostart behaviour of the scrobbler"
+ "backlog:Manage the not-yet-synced backlog of watched media"
+ "config:Edit the scrobbler config settings"
+ "help:Display the manual of a command"
+ "init:Run the initial setup of the scrobble"
+ "log:Access the log file"
+ "plex:Run the authetication flow for plex media server"
+ "run:Run the scrobbler in the foreground"
+ "start:Start the trakt-scrobbler service"
+ "status:Show the status trakt-scrobbler service"
+ "stop:Stop the trakt-scrobbler service"
+ "whitelist:Add the given folder(s) to whitelist"
+ )
+ _describe 'actions' actions
+}
+# command: trakts
+local line args
+args=(
+ "1:actions:_trakts_actions"
+ {-h,--help}"[Display help message]"
+ {-q,--quiet}"[Do not output any message]"
+ {-v,--verbose}"[Increase the verbosity of messages]"
+ {-V,--version}"[Display this application version]"
+ {-n,--no-interaction}"[Do not ask any interactive question]"
+ "--ansi[Force ANSI output]"
+ "--no-ansi[Disable ANSI output]"
+ "*::arg:->args"
+)
+_arguments -s "${args[@]}"
+case $line[1] in
+ (help)
+ case $CURRENT in
+ (2)
+ _trakts_actions "$@"
+ ;;
+ (3)
+ if [ -n "$functions[_trakts_$line[2]_actions]" ];then
+ _trakts_$line[2]_actions "$@"
+ fi
+ ;;
+ (4)
+ if [ -n "$functions[_trakts_$line[2]_$line[3]_actions]" ];then
+ _trakts_$line[2]_$line[3]_actions "$@"
+ fi
+ ;;
+ (5)
+ if [ -n "$functions[_trakts_$line[2]_$line[3]_$line[4]_actions]" ];then
+ _trakts_$line[2]_$line[3]_$line[4]_actions "$@"
+ fi
+ ;;
+ (6)
+ if [ -n "$functions[_trakts_$line[2]_$line[3]_$line[4]_$line[5]_actions]" ];then
+ _trakts_$line[2]_$line[3]_$line[4]_$line[5]_actions "$@"
+ fi
+ ;;
+ esac
+ ;;
+ (auth)
+ _arguments '-f[Force run the flow]'
+ ;;
+ (*)
+ if [ -n "$functions[_trakts_$line[1]]" ] ;then
+ _trakts_$line[1] "$@"
+ fi
+ ;;
+esac