Sha256: 37d15def8468c09cfa9fef06b5f7510ab581ee327ca46780bf39f4859723a704

Contents?: true

Size: 883 Bytes

Versions: 17

Compression:

Stored size: 883 Bytes

Contents

# frozen_string_literal: true

# tau ship completion bash
module ShipCompletionBash
  # Print bash completion code
  def ship_completion_bash
    tau_completion = Takeltau::CLI.new.bash_fylla
    completion = _ship_completion_bash_remove_lines tau_completion
    completion = _ship_completion_bash_remove_functions completion
    completion << 'complete -F _ship ship'
    completion
  end

  private

  # Remove bash completion lines
  def _ship_completion_bash_remove_lines(tau_completion)
    completion =
      tau_completion
      .strip.split("\n")
    completion.pop
    completion.join("\n")
  end

  # Remove bash completion functions
  def _ship_completion_bash_remove_functions(completion)
    functions =
      completion
      .split(/_tau[^_]*/)
      .grep(/_ship/)
      .grep_v(/_ship\n/)
      .grep_v(/"--help"/)
      .grep_v(/"-h"/)
    functions.join
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
takeltau-0.46.9 lib/takeltau/ship/completion/bash.rb
takeltau-0.46.8 lib/takeltau/ship/completion/bash.rb
takeltau-0.46.5 lib/takeltau/ship/completion/bash.rb
takeltau-0.46.1 lib/takeltau/ship/completion/bash.rb
takeltau-0.46.0 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.27 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.26 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.24 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.23 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.22 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.21 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.19 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.17 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.16 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.14 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.13 lib/takeltau/ship/completion/bash.rb
takeltau-0.45.12 lib/takeltau/ship/completion/bash.rb