Sha256: da318ebfaeb72058cdeee29773fee98bfb9ac77953dbce07d4456b48df47f01f

Contents?: true

Size: 937 Bytes

Versions: 40

Compression:

Stored size: 937 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

40 entries across 40 versions & 1 rubygems

Version Path
takeltau-0.42.3 lib/takeltau/self/commands.rb
takeltau-0.42.0 lib/takeltau/self/commands.rb
takeltau-0.41.10 lib/takeltau/self/commands.rb
takeltau-0.41.9 lib/takeltau/self/commands.rb
takeltau-0.41.0 lib/takeltau/self/commands.rb
takeltau-0.40.11 lib/takeltau/self/commands.rb
takeltau-0.40.9 lib/takeltau/self/commands.rb
takeltau-0.40.7 lib/takeltau/self/commands.rb
takeltau-0.40.6 lib/takeltau/self/commands.rb
takeltau-0.40.4 lib/takeltau/self/commands.rb
takeltau-0.40.3 lib/takeltau/self/commands.rb
takeltau-0.40.1 lib/takeltau/self/commands.rb
takeltau-0.40.0 lib/takeltau/self/commands.rb
takeltau-0.39.18 lib/takeltau/self/commands.rb
takeltau-0.39.16 lib/takeltau/self/commands.rb
takeltau-0.39.11 lib/takeltau/self/commands.rb
takeltau-0.39.7 lib/takeltau/self/commands.rb
takeltau-0.39.2 lib/takeltau/self/commands.rb
takeltau-0.39.0 lib/takeltau/self/commands.rb
takeltau-0.38.2 lib/takeltau/self/commands.rb