Sha256: fd53520f6581f7a6f9b77c32c58efad3b0051b591a246e428a8ddfe834b52dea

Contents?: true

Size: 838 Bytes

Versions: 3

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

# takelage self list
module SelfList
  # Backend method for config self.
  def self_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' \
        "'"
    thor_list = `#{cmd_thor_list}`

    # manipulate thor list output
    _manipulate_output_(thor_list)
  end

  private

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
takelage-0.20.2 lib/takelage/self/list.rb
takelage-0.20.1 lib/takelage/self/list.rb
takelage-0.20.0 lib/takelage/self/list.rb