blob: 5aca64f78dba2ea3e4d49c5b24505bbe6e2858ba (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# bash completion for tg_backup.py
#
# Copyright (C) 2026 Danilo M. <danix@danix.xyz>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
_tg_backup() {
local cur prev opts
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
opts="--target --archive-dir --list-chats --force-target --self-check --help"
# --archive-dir takes a directory. Handles both "--archive-dir <tab>" and
# the --opt=value form, where bash leaves the = in prev.
case $prev in
--archive-dir)
_filedir -d
return
;;
esac
if [[ $cur == --archive-dir=* ]]; then
cur=${cur#--archive-dir=}
_filedir -d
return
fi
# --target is a chat: no local source of completions without hitting the
# network, so offer only the one value that is not chat-specific.
if [[ $prev == --target || $cur == --target=* ]]; then
[[ $cur == --target=* ]] && cur=${cur#--target=}
COMPREPLY=($(compgen -W "me" -- "$cur"))
return
fi
COMPREPLY=($(compgen -W "$opts" -- "$cur"))
}
complete -F _tg_backup tg_backup.py tg_backup
|