@shutootaki/gwm
Version:
git worktree manager CLI
69 lines (57 loc) • 2.08 kB
JavaScript
/**
* fish 補完スクリプト生成
*/
/**
* fish 補完スクリプトを生成
* @param _definition 補完定義(将来の定義駆動生成に備えて予約)
* @returns fish 補完スクリプト文字列
*/
export function generateFishScript(_definition) {
return `# gwm fish completion script
# Generated by gwm completion
#
# Installation:
# gwm completion install --shell fish
#
# Manual installation:
# Copy this file to ~/.config/fish/completions/gwm.fish
# 補完候補を取得する関数
function __gwm_complete
# コマンドライン引数を取得(gwm 自体を除く)
set -l tokens (commandline -opc)
set -l count (count $tokens)
# gwm 自体を除いた引数
if test $count -gt 1
set tokens $tokens[2..-1]
set count (math $count - 1)
else
set tokens
set count 0
end
# gwm completion __complete を呼び出し
gwm completion __complete --shell fish --cword $count -- $tokens 2>/dev/null
end
# gwm コマンドの補完を登録
complete -c gwm -f -a '(__gwm_complete)'
# サブコマンドごとの静的補完も追加(フォールバック用)
# list / ls
complete -c gwm -n '__fish_use_subcommand' -a 'list' -d 'List all worktrees'
complete -c gwm -n '__fish_use_subcommand' -a 'ls' -d 'List all worktrees (alias)'
# add
complete -c gwm -n '__fish_use_subcommand' -a 'add' -d 'Create a new worktree'
# go
complete -c gwm -n '__fish_use_subcommand' -a 'go' -d 'Go to a worktree directory'
# remove / rm
complete -c gwm -n '__fish_use_subcommand' -a 'remove' -d 'Remove worktrees'
complete -c gwm -n '__fish_use_subcommand' -a 'rm' -d 'Remove worktrees (alias)'
# clean
complete -c gwm -n '__fish_use_subcommand' -a 'clean' -d 'Clean up safe-to-delete worktrees'
# pull-main
complete -c gwm -n '__fish_use_subcommand' -a 'pull-main' -d 'Update main branch worktrees'
# help
complete -c gwm -n '__fish_use_subcommand' -a 'help' -d 'Show help'
# completion
complete -c gwm -n '__fish_use_subcommand' -a 'completion' -d 'Manage shell completion'
`;
}
//# sourceMappingURL=fish.js.map