ailock
Version:
AI-Proof File Guard - Protect sensitive files from accidental AI modifications
156 lines (140 loc) • 5.29 kB
JavaScript
/**
* Generate Bash completion script for ailock
*/
export function generateBashCompletion() {
return `#!/usr/bin/env bash
# ailock bash completion script
# Generated by: ailock completion bash
_ailock_completion() {
local cur prev words cword
# Initialize completion variables
if type _init_completion &>/dev/null; then
_init_completion || return
else
# Fallback for systems without bash-completion
cur="\${COMP_WORDS[COMP_CWORD]}"
prev="\${COMP_WORDS[COMP_CWORD-1]}"
words=("\${COMP_WORDS[@]}")
cword=\$COMP_CWORD
fi
local commands="init lock unlock status status-interactive list ls diagnose generate install-hooks completion setup-completion help"
# Main command completion
if [[ $cword -eq 1 ]]; then
COMPREPLY=($(compgen -W "$commands" -- "$cur"))
return
fi
# Get the command
local cmd="\${words[1]}"
# Command-specific completions
case "$cmd" in
init)
case "$prev" in
init)
COMPREPLY=($(compgen -W "--force --interactive --config-only" -- "$cur"))
;;
esac
;;
lock)
case "$prev" in
lock)
# Mix of options and file completions
local options="--verbose --dry-run --no-gitignore"
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "$options" -- "$cur"))
else
# Get file suggestions from completion helper
local files=$(ailock completion-helper --type unlocked-files --partial "$cur" 2>/dev/null)
if [[ -n "$files" ]]; then
COMPREPLY=($(compgen -W "$files" -- "$cur"))
else
# Fallback to standard file completion
# Fallback to file completion
COMPREPLY=($(compgen -f -- "$cur"))
fi
fi
;;
*)
# Additional file arguments
# File completion
COMPREPLY=($(compgen -f -- "$cur"))
;;
esac
;;
unlock)
case "$prev" in
unlock)
local options="--verbose --dry-run --all --no-gitignore"
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "$options" -- "$cur"))
else
# Get locked files for unlock
local files=$(ailock completion-helper --type locked-files --partial "$cur" 2>/dev/null)
if [[ -n "$files" ]]; then
COMPREPLY=($(compgen -W "$files" -- "$cur"))
else
# Fallback to file completion
COMPREPLY=($(compgen -f -- "$cur"))
fi
fi
;;
*)
# File completion
COMPREPLY=($(compgen -f -- "$cur"))
;;
esac
;;
status)
COMPREPLY=($(compgen -W "--verbose --simple --json" -- "$cur"))
;;
list|ls)
COMPREPLY=($(compgen -W "--all --long --locked-only --unlocked-only --json" -- "$cur"))
;;
diagnose)
case "$prev" in
diagnose)
if [[ "$cur" == -* ]]; then
COMPREPLY=($(compgen -W "--verbose" -- "$cur"))
else
# File completion
COMPREPLY=($(compgen -f -- "$cur"))
fi
;;
esac
;;
generate)
case "$prev" in
generate)
COMPREPLY=($(compgen -W "github gitlab bitbucket jenkins circleci docker devcontainer" -- "$cur"))
;;
esac
;;
install-hooks)
COMPREPLY=($(compgen -W "--force --yes" -- "$cur"))
;;
completion)
case "$prev" in
completion)
COMPREPLY=($(compgen -W "bash zsh fish powershell" -- "$cur"))
;;
bash|zsh|fish|powershell)
COMPREPLY=($(compgen -W "--install-instructions" -- "$cur"))
;;
esac
;;
esac
}
# Support both ailock and aiunlock commands
complete -F _ailock_completion ailock
complete -F _ailock_completion aiunlock
# Lazy loading optimization for faster shell startup
# Uncomment the following to enable lazy loading:
# _ailock_lazy_loader() {
# _ailock_completion "$@"
# complete -F _ailock_completion ailock
# complete -F _ailock_completion aiunlock
# }
# complete -F _ailock_lazy_loader ailock
# complete -F _ailock_lazy_loader aiunlock
`;
}
//# sourceMappingURL=bash.js.map