Sha256: 82175c4ac0ac25ef10f1d2e137ebc19d0bc02c80afdfc154133f28154a9f36e7

Contents?: true

Size: 894 Bytes

Versions: 5

Compression:

Stored size: 894 Bytes

Contents

# frozen_string_literal: true

# tau self list
module SelfList
  # Backend method for config self.
  def self_list
    _manipulate_output_(_get_thor_list_)
  end

  private

  # Get output of thor list command.
  def _get_thor_list_
    # use Thorfile which requires relative takelage.rb
    thorfile_dir = "#{File.dirname(__FILE__)}/../"

    # use thor list to get the list of commands and subcommands
    cmd_thor_list = "bash -c '" \
        "cd #{thorfile_dir} && " \
        'thor list' \
        "'"

    # call thor list command
    `#{cmd_thor_list}`
  end

  # Manipulate output of thor list command.
  def _manipulate_output_(thor_list)
    tau_list = thor_list.gsub("takeltau\n", '')
    tau_list.gsub!("------\n", '')
    tau_list.gsub!('thor ', 'tau ')
    tau_list.gsub!(/(.*)takeltau:c_l_i:(.*)#(.*)/, '\1\2               #\3')
    tau_list.gsub!(/.*COMMAND.*\n/, '')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
takeltau-0.35.18 lib/takeltau/self/list.rb
takeltau-0.35.15 lib/takeltau/self/list.rb
takeltau-0.35.14 lib/takeltau/self/list.rb
takeltau-0.35.12 lib/takeltau/self/list.rb
takeltau-0.35.11 lib/takeltau/self/list.rb