#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.]' \ {--relative,-R}'[User relative path names.]' \ '--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.]' \ '--exclude[Interpret positional arguments as blacklist]' \ '*:file or directory:_files' } _msynk "$@"