Skip to content

Commit

Permalink
Add test autocompletion for fish
Browse files Browse the repository at this point in the history
  • Loading branch information
tanishiking committed Dec 5, 2018
1 parent e8af025 commit 8deccc2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion etc/fish/bloop.fish
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ function __fish_seen_subcommand_from_project_commands
__fish_seen_subcommand_from $prj
end

# https://github.com/fish-shell/fish-shell/blob/04795eb8ea63e9b68bc85342aae81b9a60cd09c8/share/functions/__fish_prev_arg_in.fish
function __fish_prev_arg_in
set -l tokens (commandline -co)
set -l tokenCount (count $tokens)
if test $tokenCount -lt 2
# need at least cmd and prev argument
return 1
end
for arg in $argv
if string match -q -- $tokens[-1] $argv[0]
return 0
end
end

return 1
end

function _flags_for_command -a cmd
bloop autocomplete --format fish --mode flags --command $cmd
end
Expand All @@ -82,6 +99,8 @@ complete -c bloop -f -n "__assert_args_count 0" -a '(_commands)'
# Only a project command has been provided
complete -c bloop -f -n "__assert_args_count 1; and __fish_seen_subcommand_from_project_commands" -a '(_projects)'

# Only a project command has been provided
complete -c bloop -x -n "__fish_seen_subcommand_from test; and not __fish_prev_arg_in --only" -a '(_testsfqcn)'

for cmd in (_commands)
set -l minTokens (_is_project_command $cmd)
Expand All @@ -98,4 +117,4 @@ for cmd in (_commands)
_bloop_cmpl_ $minTokens $cmd -l $parsed[1]
end
end
end
end

0 comments on commit 8deccc2

Please sign in to comment.