-
Notifications
You must be signed in to change notification settings - Fork 683
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add command-line completions for fish shell
Since the command to enable them is different, also make that change in the output based on the shell used. Signed-off-by: Nathan L Smith <smith@chef.io>
- Loading branch information
Nathan L Smith
committed
May 4, 2017
1 parent
bfda54f
commit e3c62ec
Showing
2 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function __fish_inspec_no_command --description 'Test if inspec has yet to be given the main command' | ||
set -l cmd (commandline -opc) | ||
test (count $cmd) -eq 1 | ||
end | ||
|
||
function __fish_inspec_using_command | ||
set -l cmd (commandline -opc) | ||
set -q cmd[2]; and test "$argv[1]" = $cmd[2] | ||
end | ||
|
||
function __fish_inspec_using_command_and_no_subcommand | ||
set -l cmd (commandline -opc) | ||
test (count $cmd) -eq 2; and test "$argv[1]" = "$cmd[2]" | ||
end | ||
|
||
function __fish_inspec_using_subcommand --argument-names cmd_main cmd_sub | ||
set -l cmd (commandline -opc) | ||
set -q cmd[3]; and test "$cmd_main" = $cmd[2] -a "$cmd_sub" = $cmd[3] | ||
end | ||
|
||
<% top_level_commands_with_descriptions.each do |command_and_description| %> | ||
<% command, description = command_and_description.split(':') %> | ||
<% description.gsub!(/\\/, '') %> | ||
# <%= command %> commands | ||
complete -c inspec -f -n '__fish_inspec_no_command' -a <%= command %> -d "<%= description %>" | ||
# <%= command %> help | ||
complete -c inspec -f -n '__fish_inspec_using_command help' -a <%= command %> -d "<%= description %>" | ||
|
||
<% (subcommands_with_commands_and_descriptions[command] || []).each do |command_and_description| %> | ||
<% subcommand, description = command_and_description.split(':') %> | ||
<% description.gsub!(/\\/, '') %> | ||
complete -c inspec -f -n '__fish_inspec_using_command_and_no_subcommand <%= command %>' -a <%= subcommand %> -d "<%= description %>" | ||
<% end %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters