Module: Bashly::Completions::Flag

Included in:
Script::Flag
Defined in:
lib/bashly/concerns/completions.rb

Instance Method Summary collapse

Instance Method Details

#completion_data(command_full_name) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/bashly/concerns/completions.rb', line 8

def completion_data(command_full_name)
  comps = allowed || completions
  return {} unless comps

  aliases.to_h do |name|
    prefix = command_full_name
    prefix = "#{prefix}*" unless prefix.end_with? '*'
    ["#{prefix}#{name}",  comps]
  end
end