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 6, 2018
1 parent fcec653 commit a7f257e
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion etc/fish/bloop.fish
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ function __assert_args_at_least_count -a count
test (count $cmd) -ge $count
end

function __assert_prev_arg_in
set -l tokens (commandline -poc)
if not __assert_args_at_least_count 1
return 0
end
for arg in $argv
if string match -q -- $tokens[-1] $argv[0]
return 1
end
end
return 0
end

function _project_commands
bloop autocomplete --format bash --mode project-commands 2> /dev/null
end
Expand Down Expand Up @@ -82,6 +95,7 @@ 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)'

complete -c bloop -x -n "__fish_seen_subcommand_from test; and __assert_prev_arg_in --only -o" -a '(_testsfqcn)'

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

0 comments on commit a7f257e

Please sign in to comment.