Sha256: 869300e1659c94ac8606cf69cda4346f5405d1c983686601b0819eb73994fd52

Contents?: true

Size: 1.06 KB

Versions: 9

Compression:

Stored size: 1.06 KB

Contents

module Foobara
  module CommandConnectors
    module Commands
      class ListCommands < Command
        inputs request: :duck, # TODO: have some way to specify by Ruby class...
               verbose: :boolean

        result [
          [
            :string,
            {
              type: :string,
              allow_nil: true
            }
          ]
        ]

        def execute
          build_list
          build_result
        end

        attr_accessor :list

        def build_list
          self.list = command_connector.command_registry.all_transformed_command_classes
        end

        def verbose?
          verbose
        end

        def build_result
          if verbose?
            list.map do |command_class|
              [command_class.full_command_name, command_class.description]
            end
          else
            list.map do |command_class|
              [command_class.full_command_name, nil]
            end
          end
        end

        def command_connector
          request.command_connector
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
foobara-0.0.9 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.8 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.7 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.6 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.5 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.4 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.3 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.2 projects/command_connectors/src/commands/list_commands.rb
foobara-0.0.1 projects/command_connectors/src/commands/list_commands.rb