Sha256: 0bf9a1e8b94f697c6b4c4193dc8c2375746100299fadd0d7a2efe707bddb764e

Contents?: true

Size: 1.43 KB

Versions: 6

Compression:

Stored size: 1.43 KB

Contents

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 %>

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
inspec-2.1.81 lib/inspec/completions/fish.sh.erb
inspec-2.1.21 lib/inspec/completions/fish.sh.erb
inspec-2.1.10 lib/inspec/completions/fish.sh.erb
inspec-2.0.32 lib/inspec/completions/fish.sh.erb
inspec-2.0.17 lib/inspec/completions/fish.sh.erb
inspec-1.51.15 lib/inspec/completions/fish.sh.erb