Sha256: 7839775350d74c2233ca7492ee9001ad09f8aa0c55c3731bd6cf0b210325b52e

Contents?: true

Size: 972 Bytes

Versions: 37

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

# tau self commands
module SelfCommands
  # Backend method for config self commands.
  def self_commands
    _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_commands = thor_list.gsub("takeltau\n", '')
    tau_commands.gsub!("--------\n", '')
    tau_commands.gsub!('thor ', 'tau ')
    tau_commands.gsub!(/(.*)takeltau:c_l_i:(.*)#(.*)/, '\1\2               #\3')
    tau_commands.gsub!(/.*COMMAND.*\n/, '')
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
takeltau-0.46.9 lib/takeltau/self/commands.rb
takeltau-0.46.8 lib/takeltau/self/commands.rb
takeltau-0.46.5 lib/takeltau/self/commands.rb
takeltau-0.46.1 lib/takeltau/self/commands.rb
takeltau-0.46.0 lib/takeltau/self/commands.rb
takeltau-0.45.27 lib/takeltau/self/commands.rb
takeltau-0.45.26 lib/takeltau/self/commands.rb
takeltau-0.45.24 lib/takeltau/self/commands.rb
takeltau-0.45.23 lib/takeltau/self/commands.rb
takeltau-0.45.22 lib/takeltau/self/commands.rb
takeltau-0.45.21 lib/takeltau/self/commands.rb
takeltau-0.45.19 lib/takeltau/self/commands.rb
takeltau-0.45.17 lib/takeltau/self/commands.rb
takeltau-0.45.16 lib/takeltau/self/commands.rb
takeltau-0.45.14 lib/takeltau/self/commands.rb
takeltau-0.45.13 lib/takeltau/self/commands.rb
takeltau-0.45.12 lib/takeltau/self/commands.rb
takeltau-0.45.11 lib/takeltau/self/commands.rb
takeltau-0.45.10 lib/takeltau/self/commands.rb
takeltau-0.45.9 lib/takeltau/self/commands.rb