Sha256: 6b5674b707e797d0eb76367c0656d4174d0db0d567491a0227b65bd1ec8c08e3

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

require 'canals'
require 'canals/options'
require 'canals/environment'
require 'thor'

module Canals
  module Cli
    class List < Thor
      include Thor::Actions

      desc 'environments', 'List the different environments'
      def environments
        envs = Canals.environments.map{ |conf| conf.name }
        say envs.sort.join " "
      end

      desc 'tunnels', 'List the different tunnels'
      def tunnels
        tunnels = Canals.repository.map{ |conf| conf.name }
        say tunnels.sort.join " "
      end

      desc 'session', 'List the tunnels in the current session'
      def session
        tunnels = Canals.session.map{ |conf| conf[:name] }
        say tunnels.sort.join " "
      end

      desc 'commands', 'List all the base level commands'
      def commands(subcommand=nil)
        thor_class = Canals::Cli::Application
        if !subcommand.nil?
          thor_class = thor_class.subcommand_classes[subcommand]
          if thor_class.nil?
            return
          end
        end

        cmds = thor_class.all_commands.values.select{ |c| c.class == Thor::Command }.map{ |c| c.name }
        say cmds.sort.join " "
      end

    end
  end
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
canals-0.9.1 lib/canals/cli/list.rb
canals-0.9.0 lib/canals/cli/list.rb