Sha256: d69e002439212442d4cd841259009b94cfed630a9a138728a0d5569e66ee87d3

Contents?: true

Size: 1.88 KB

Versions: 20

Compression:

Stored size: 1.88 KB

Contents

#!/usr/bin/env ruby
#
# Copyright (C) 2013 Conjur Inc
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of
# this software and associated documentation files (the "Software"), to deal in
# the Software without restriction, including without limitation the rights to
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
# the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

# You can use this file by adding the following to something that gets sourced (like .bashrc)
#
# _conjur()
# {
#     COMPREPLY=($(_conjur_completions $COMP_CWORD ${COMP_WORDS[@]}))
# }
# complete -F _conjur conjur

require 'yaml'
completions = File.open("#{File.dirname(__FILE__)}/_conjur_completions.yaml"){ |_| YAML.load(_) }
# ARGV[0] is the index into ARGV[1...] of the current word
index = ARGV[0].to_i - 1
words = ARGV[2..-1]
parents = words[0...index]
word = words[index] || ""

current = completions
previous = current
until parents.empty? or current.nil? or not current.kind_of?(Hash) # make sure to stop if we hit a 'true' entry
  previous = current
  current = current[parents.shift.to_sym]
end

if current.kind_of?(Hash)
  puts current.keys.map(&:to_s).select{|k| k.start_with?(word)}.sort.join("\n")
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
conjur-cli-4.25.2 bin/_conjur_completions
conjur-cli-4.25.1 bin/_conjur_completions
conjur-cli-4.25.0 bin/_conjur_completions
conjur-cli-4.24.0 bin/_conjur_completions
conjur-cli-4.23.0 bin/_conjur_completions
conjur-cli-4.22.0 bin/_conjur_completions
conjur-cli-4.21.1 bin/_conjur_completions
conjur-cli-4.21.0 bin/_conjur_completions
conjur-cli-4.20.1 bin/_conjur_completions
conjur-cli-4.19.0 bin/_conjur_completions
conjur-cli-4.18.6 bin/_conjur_completions
conjur-cli-4.18.0 bin/_conjur_completions
conjur-cli-4.17.0 bin/_conjur_completions
conjur-cli-4.16.0 bin/_conjur_completions
conjur-cli-4.15.0 bin/_conjur_completions
conjur-cli-4.14.0 bin/_conjur_completions
conjur-cli-4.13.1 bin/_conjur_completions
conjur-cli-4.12.0 bin/_conjur_completions
conjur-cli-4.10.3 bin/_conjur_completions
conjur-cli-4.10.1 bin/_conjur_completions