diff --git a/_msynk.compdef.zsh b/_msynk.compdef.zsh new file mode 100644 index 0000000..d04fd0b --- /dev/null +++ b/_msynk.compdef.zsh @@ -0,0 +1,37 @@ +#compdef msynk +# https://zsh.sourceforge.io/Doc/Release/Completion-System.html#Completion-Functions +_config-file() +{ + # list all files in $CONFIG_DIR + [[ -z $XDG_CONFIG_HOME ]] && XDG_CONFIG_HOME=~/.config + opts=($(ls $XDG_CONFIG_HOME/msynk)) + # -s separator, descritions options + _values -s , 'config files' $opts +} +_msynk() +{ + # each argument is + # n:message:action + # option[description]:message:action + # *option offer multiple times + _arguments \ + {--help,-h}'[We all need it at times...]' \ + {--settings,-s}'[Show current settings.]' \ + {--config,-c}'[Use sender, receiver, paths from config file]':config:_config-file \ + '--show-config[Print variables defined by a config file.]':config:_config-file \ + {--sender,-s}'[Sender directory, with trailing "/".]':directory:_directories \ + {--receiver,-r}'[Receiver directory, with trailing "/".]':directory:_directories \ + '--reverse[Swap receiver and sender.]' \ + '--encrypt[Encrypt files before syncing.]' \ + '--decrypt[Decrypt files before syncing.]' \ + '--check-date[Only process files that have been modified since the program was last run. Needs -c and (--encrypt/--decrypt).]' \ + '*--mkrypt-flag[Additional argument for mkrypt.]':mkrypt-flag:_mkrypt \ + {--delete,-d}'[Delete files that exist on receiver, but not on sender. Does not work with --encrypt/--decrypt.]' \ + '--skip-dryrun[Delete without asking first.]' \ + '*--rsync-flag[Additional argument for rsync.]':rsync-flag:_rsync \ + {--verbose,-v}'[Increase verbosity.]' \ + '--silent[Decrease verbosity.]' \ + '--debug[Maximum verbosity.]' \ + '*:file or directory:_files' +} +_msynk "$@"