forked from claw/flaskpaste
Audit logging: - audit_log table with event tracking - app/audit.py module with log_event(), query_audit_log() - GET /audit endpoint (admin only) - configurable retention and cleanup Prometheus metrics: - app/metrics.py with custom counters - paste create/access/delete, rate limit, PoW, dedup metrics - instrumentation in API routes CLI clipboard integration: - fpaste create -C/--clipboard (read from clipboard) - fpaste create --copy-url (copy result URL) - fpaste get -c/--copy (copy content) - cross-platform: xclip, xsel, pbcopy, wl-copy Shell completions: - completions/ directory with bash/zsh/fish scripts - fpaste completion --shell command
203 lines
6.4 KiB
Bash
203 lines
6.4 KiB
Bash
# Bash completion for fpaste
|
|
# Install: source this file or copy to /etc/bash_completion.d/fpaste
|
|
|
|
_fpaste_completions() {
|
|
local cur prev words cword
|
|
_init_completion || return
|
|
|
|
local commands="create c new get g delete d rm info i list ls search s find update u export register cert pki completion"
|
|
local pki_commands="status issue download dl"
|
|
|
|
# Handle command-level completion
|
|
if [[ $cword -eq 1 ]]; then
|
|
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
|
|
return
|
|
fi
|
|
|
|
local cmd="${words[1]}"
|
|
|
|
# PKI subcommand completion
|
|
if [[ "$cmd" == "pki" && $cword -eq 2 ]]; then
|
|
COMPREPLY=($(compgen -W "$pki_commands" -- "$cur"))
|
|
return
|
|
fi
|
|
|
|
# Option completion based on command
|
|
case "$cmd" in
|
|
create|c|new)
|
|
case "$prev" in
|
|
-x|--expiry)
|
|
# Suggest common expiry values
|
|
COMPREPLY=($(compgen -W "60 300 600 3600 86400 604800" -- "$cur"))
|
|
return
|
|
;;
|
|
-p|--password)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-E --no-encrypt -b --burn -x --expiry -p --password -r --raw -q --quiet -C --clipboard --copy-url" -- "$cur"))
|
|
else
|
|
_filedir
|
|
fi
|
|
;;
|
|
get|g)
|
|
case "$prev" in
|
|
-o|--output)
|
|
_filedir
|
|
return
|
|
;;
|
|
-p|--password)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-o --output -c --copy -p --password -m --meta" -- "$cur"))
|
|
fi
|
|
;;
|
|
delete|d|rm)
|
|
case "$prev" in
|
|
-c|--confirm)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-a --all -c --confirm" -- "$cur"))
|
|
fi
|
|
;;
|
|
info|i)
|
|
# No options
|
|
;;
|
|
list|ls)
|
|
case "$prev" in
|
|
-l|--limit|-o|--offset)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-a --all -l --limit -o --offset --json" -- "$cur"))
|
|
fi
|
|
;;
|
|
search|s|find)
|
|
case "$prev" in
|
|
-t|--type)
|
|
COMPREPLY=($(compgen -W "text/* image/* application/*" -- "$cur"))
|
|
return
|
|
;;
|
|
--after|--before)
|
|
return
|
|
;;
|
|
-l|--limit)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-t --type --after --before -l --limit --json" -- "$cur"))
|
|
fi
|
|
;;
|
|
update|u)
|
|
case "$prev" in
|
|
-x|--expiry)
|
|
COMPREPLY=($(compgen -W "60 300 600 3600 86400 604800" -- "$cur"))
|
|
return
|
|
;;
|
|
-p|--password)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-E --no-encrypt -p --password --remove-password -x --expiry -q --quiet" -- "$cur"))
|
|
else
|
|
_filedir
|
|
fi
|
|
;;
|
|
export)
|
|
case "$prev" in
|
|
-o|--output|-k|--keyfile)
|
|
_filedir
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-o --output -k --keyfile --manifest -q --quiet" -- "$cur"))
|
|
fi
|
|
;;
|
|
register)
|
|
case "$prev" in
|
|
-n|--name|-o|--output)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-n --name -o --output --configure --p12-only -f --force -q --quiet" -- "$cur"))
|
|
fi
|
|
;;
|
|
cert)
|
|
case "$prev" in
|
|
-o|--output)
|
|
_filedir -d
|
|
return
|
|
;;
|
|
-a|--algorithm)
|
|
COMPREPLY=($(compgen -W "rsa ec" -- "$cur"))
|
|
return
|
|
;;
|
|
-c|--curve)
|
|
COMPREPLY=($(compgen -W "secp256r1 secp384r1 secp521r1" -- "$cur"))
|
|
return
|
|
;;
|
|
-b|--bits|-d|--days|-n|--name|--password-key)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-o --output -a --algorithm -b --bits -c --curve -d --days -n --name --password-key --configure -f --force" -- "$cur"))
|
|
fi
|
|
;;
|
|
pki)
|
|
local pki_cmd="${words[2]}"
|
|
case "$pki_cmd" in
|
|
issue)
|
|
case "$prev" in
|
|
-n|--name|-o|--output)
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-n --name -o --output --configure -f --force" -- "$cur"))
|
|
fi
|
|
;;
|
|
download|dl)
|
|
case "$prev" in
|
|
-o|--output)
|
|
_filedir
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "-o --output --configure" -- "$cur"))
|
|
fi
|
|
;;
|
|
esac
|
|
;;
|
|
completion)
|
|
case "$prev" in
|
|
--shell)
|
|
COMPREPLY=($(compgen -W "bash zsh fish" -- "$cur"))
|
|
return
|
|
;;
|
|
esac
|
|
if [[ "$cur" == -* ]]; then
|
|
COMPREPLY=($(compgen -W "--shell" -- "$cur"))
|
|
fi
|
|
;;
|
|
esac
|
|
|
|
# Global options
|
|
if [[ "$cur" == -* && $cword -eq 1 ]]; then
|
|
COMPREPLY=($(compgen -W "-s --server -h --help" -- "$cur"))
|
|
fi
|
|
}
|
|
|
|
complete -F _fpaste_completions fpaste
|